File tree 2 files changed +41
-50
lines changed
src/test/ui/array-slice-vec
2 files changed +41
-50
lines changed Original file line number Diff line number Diff line change @@ -1870,3 +1870,44 @@ fn test_vec_cycle() {
1870
1870
c3. v [ 0 ] . set ( Some ( & c1) ) ;
1871
1871
c3. v [ 1 ] . set ( Some ( & c2) ) ;
1872
1872
}
1873
+
1874
+ #[ test]
1875
+ fn test_vec_cycle_wrapped ( ) {
1876
+ struct Refs < ' a > {
1877
+ v : Vec < Cell < Option < & ' a C < ' a > > > > ,
1878
+ }
1879
+
1880
+ struct C < ' a > {
1881
+ refs : Refs < ' a > ,
1882
+ }
1883
+
1884
+ impl < ' a > Refs < ' a > {
1885
+ fn new ( ) -> Refs < ' a > {
1886
+ Refs { v : Vec :: new ( ) }
1887
+ }
1888
+ }
1889
+
1890
+ impl < ' a > C < ' a > {
1891
+ fn new ( ) -> C < ' a > {
1892
+ C { refs : Refs :: new ( ) }
1893
+ }
1894
+ }
1895
+
1896
+ let mut c1 = C :: new ( ) ;
1897
+ let mut c2 = C :: new ( ) ;
1898
+ let mut c3 = C :: new ( ) ;
1899
+
1900
+ c1. refs . v . push ( Cell :: new ( None ) ) ;
1901
+ c1. refs . v . push ( Cell :: new ( None ) ) ;
1902
+ c2. refs . v . push ( Cell :: new ( None ) ) ;
1903
+ c2. refs . v . push ( Cell :: new ( None ) ) ;
1904
+ c3. refs . v . push ( Cell :: new ( None ) ) ;
1905
+ c3. refs . v . push ( Cell :: new ( None ) ) ;
1906
+
1907
+ c1. refs . v [ 0 ] . set ( Some ( & c2) ) ;
1908
+ c1. refs . v [ 1 ] . set ( Some ( & c3) ) ;
1909
+ c2. refs . v [ 0 ] . set ( Some ( & c2) ) ;
1910
+ c2. refs . v [ 1 ] . set ( Some ( & c3) ) ;
1911
+ c3. refs . v [ 0 ] . set ( Some ( & c1) ) ;
1912
+ c3. refs . v [ 1 ] . set ( Some ( & c2) ) ;
1913
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments