Skip to content

Commit 8904921

Browse files
committed
Move array cycle test
1 parent ac39deb commit 8904921

File tree

2 files changed

+29
-31
lines changed

2 files changed

+29
-31
lines changed

library/core/tests/array.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,3 +330,32 @@ fn array_map_drop_safety() {
330330
assert_eq!(DROPPED.load(Ordering::SeqCst), num_to_create);
331331
panic!("test succeeded")
332332
}
333+
334+
#[test]
335+
fn cell_allows_array_cycle() {
336+
use core::cell::Cell;
337+
338+
#[derive(Debug)]
339+
struct B<'a> {
340+
a: [Cell<Option<&'a B<'a>>>; 2],
341+
}
342+
343+
impl<'a> B<'a> {
344+
fn new() -> B<'a> {
345+
B { a: [Cell::new(None), Cell::new(None)] }
346+
}
347+
}
348+
349+
let b1 = B::new();
350+
let b2 = B::new();
351+
let b3 = B::new();
352+
353+
b1.a[0].set(Some(&b2));
354+
b1.a[1].set(Some(&b3));
355+
356+
b2.a[0].set(Some(&b2));
357+
b2.a[1].set(Some(&b3));
358+
359+
b3.a[0].set(Some(&b1));
360+
b3.a[1].set(Some(&b2));
361+
}

src/test/ui/array-slice-vec/arr_cycle.rs

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)