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 @@ -1980,3 +1980,32 @@ fn test_is_sorted() {
1980
1980
assert ! ( ![ "c" , "bb" , "aaa" ] . is_sorted( ) ) ;
1981
1981
assert ! ( [ "c" , "bb" , "aaa" ] . is_sorted_by_key( |s| s. len( ) ) ) ;
1982
1982
}
1983
+
1984
+ #[ test]
1985
+ fn test_slice_run_destructors ( ) {
1986
+ use core:: cell:: Cell ;
1987
+
1988
+ // Make sure that destructors get run on slice literals
1989
+ struct Foo < ' a > {
1990
+ x : & ' a Cell < isize > ,
1991
+ }
1992
+
1993
+ impl < ' a > Drop for Foo < ' a > {
1994
+ fn drop ( & mut self ) {
1995
+ self . x . set ( self . x . get ( ) + 1 ) ;
1996
+ }
1997
+ }
1998
+
1999
+ fn foo ( x : & Cell < isize > ) -> Foo < ' _ > {
2000
+ Foo { x }
2001
+ }
2002
+
2003
+ let x = & Cell :: new ( 0 ) ;
2004
+
2005
+ {
2006
+ let l = & [ foo ( x) ] ;
2007
+ assert_eq ! ( l[ 0 ] . x. get( ) , 0 ) ;
2008
+ }
2009
+
2010
+ assert_eq ! ( x. get( ) , 1 ) ;
2011
+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments