Skip to content

Commit

Permalink
Move array cycle test
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Sep 21, 2020
1 parent ac39deb commit 8904921
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 31 deletions.
29 changes: 29 additions & 0 deletions library/core/tests/array.rs
Expand Up @@ -330,3 +330,32 @@ fn array_map_drop_safety() {
assert_eq!(DROPPED.load(Ordering::SeqCst), num_to_create);
panic!("test succeeded")
}

#[test]
fn cell_allows_array_cycle() {
use core::cell::Cell;

#[derive(Debug)]
struct B<'a> {
a: [Cell<Option<&'a B<'a>>>; 2],
}

impl<'a> B<'a> {
fn new() -> B<'a> {
B { a: [Cell::new(None), Cell::new(None)] }
}
}

let b1 = B::new();
let b2 = B::new();
let b3 = B::new();

b1.a[0].set(Some(&b2));
b1.a[1].set(Some(&b3));

b2.a[0].set(Some(&b2));
b2.a[1].set(Some(&b3));

b3.a[0].set(Some(&b1));
b3.a[1].set(Some(&b2));
}
31 changes: 0 additions & 31 deletions src/test/ui/array-slice-vec/arr_cycle.rs

This file was deleted.

0 comments on commit 8904921

Please sign in to comment.