File tree Expand file tree Collapse file tree 2 files changed +39
-39
lines changed
src/test/ui/array-slice-vec Expand file tree Collapse file tree 2 files changed +39
-39
lines changed Original file line number Diff line number Diff line change 11use std:: borrow:: Cow ;
2+ use std:: cell:: Cell ;
23use std:: collections:: TryReserveError :: * ;
34use std:: fmt:: Debug ;
45use std:: iter:: InPlaceIterable ;
@@ -1831,3 +1832,41 @@ fn partialeq_vec_full() {
18311832 assert_partial_eq_valid ! ( vec2, vec3; array2, array3) ;
18321833 assert_partial_eq_valid ! ( vec2, vec3; arrayref2, arrayref3) ;
18331834}
1835+
1836+ #[ test]
1837+ fn test_vec_cycle ( ) {
1838+ #[ derive( Debug ) ]
1839+ struct C < ' a > {
1840+ v : Vec < Cell < Option < & ' a C < ' a > > > > ,
1841+ }
1842+
1843+ impl < ' a > C < ' a > {
1844+ fn new ( ) -> C < ' a > {
1845+ C { v : Vec :: new ( ) }
1846+ }
1847+ }
1848+
1849+ let mut c1 = C :: new ( ) ;
1850+ let mut c2 = C :: new ( ) ;
1851+ let mut c3 = C :: new ( ) ;
1852+
1853+ // Push
1854+ c1. v . push ( Cell :: new ( None ) ) ;
1855+ c1. v . push ( Cell :: new ( None ) ) ;
1856+
1857+ c2. v . push ( Cell :: new ( None ) ) ;
1858+ c2. v . push ( Cell :: new ( None ) ) ;
1859+
1860+ c3. v . push ( Cell :: new ( None ) ) ;
1861+ c3. v . push ( Cell :: new ( None ) ) ;
1862+
1863+ // Set
1864+ c1. v [ 0 ] . set ( Some ( & c2) ) ;
1865+ c1. v [ 1 ] . set ( Some ( & c3) ) ;
1866+
1867+ c2. v [ 0 ] . set ( Some ( & c2) ) ;
1868+ c2. v [ 1 ] . set ( Some ( & c3) ) ;
1869+
1870+ c3. v [ 0 ] . set ( Some ( & c1) ) ;
1871+ c3. v [ 1 ] . set ( Some ( & c2) ) ;
1872+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments