]> git.proxmox.com Git - rustc.git/blob - src/test/ui/cell-does-not-clone.rs
New upstream version 1.47.0+dfsg1
[rustc.git] / src / test / ui / cell-does-not-clone.rs
1 // run-pass
2
3 #![allow(dead_code)]
4
5 use std::cell::Cell;
6
7 #[derive(Copy)]
8 struct Foo {
9 x: isize
10 }
11
12 impl Clone for Foo {
13 fn clone(&self) -> Foo {
14 // Using Cell in any way should never cause clone() to be
15 // invoked -- after all, that would permit evil user code to
16 // abuse `Cell` and trigger crashes.
17
18 panic!();
19 }
20 }
21
22 pub fn main() {
23 let x = Cell::new(Foo { x: 22 });
24 let _y = x.get();
25 let _z = x.clone();
26 }