File tree Expand file tree Collapse file tree 2 files changed +29
-31
lines changed
src/test/ui/array-slice-vec Expand file tree Collapse file tree 2 files changed +29
-31
lines changed Original file line number Diff line number Diff 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+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments