Skip to content

Commit

Permalink
move 'cell does not clone' test
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Sep 21, 2020
1 parent f69c5aa commit af44a2a
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 26 deletions.
23 changes: 23 additions & 0 deletions library/core/tests/cell.rs
Expand Up @@ -327,6 +327,29 @@ fn cell_exterior() {
assert_eq!(b.get().z, 13);
}

#[test]
fn cell_does_not_clone() {
#[derive(Copy)]
#[allow(dead_code)]
struct Foo {
x: isize,
}

impl Clone for Foo {
fn clone(&self) -> Foo {
// Using Cell in any way should never cause clone() to be
// invoked -- after all, that would permit evil user code to
// abuse `Cell` and trigger crashes.

panic!();
}
}

let x = Cell::new(Foo { x: 22 });
let _y = x.get();
let _z = x.clone();
}

#[test]
fn refcell_default() {
let cell: RefCell<u64> = Default::default();
Expand Down
26 changes: 0 additions & 26 deletions src/test/ui/cell-does-not-clone.rs

This file was deleted.

0 comments on commit af44a2a

Please sign in to comment.