File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,11 @@ fn array_from_ref() {
77 let value: String = "Hello World!" . into ( ) ;
88 let arr: & [ String ; 1 ] = array:: from_ref ( & value) ;
99 assert_eq ! ( & [ value. clone( ) ] , arr) ;
10+
11+ const VALUE : & & str = & "Hello World!" ;
12+ const ARR : & [ & str ; 1 ] = array:: from_ref ( VALUE ) ;
13+ assert_eq ! ( & [ * VALUE ] , ARR ) ;
14+ assert ! ( core:: ptr:: eq( VALUE , & ARR [ 0 ] ) ) ;
1015}
1116
1217#[ test]
Original file line number Diff line number Diff line change 7171#![ feature( trusted_random_access) ]
7272#![ feature( unsize) ]
7373#![ feature( unzip_option) ]
74+ #![ feature( const_array_from_ref) ]
75+ #![ feature( const_slice_from_ref) ]
7476#![ deny( unsafe_op_in_unsafe_fn) ]
7577
7678extern crate test;
Original file line number Diff line number Diff line change @@ -2146,6 +2146,14 @@ fn test_slice_run_destructors() {
21462146 assert_eq ! ( x. get( ) , 1 ) ;
21472147}
21482148
2149+ #[ test]
2150+ fn test_const_from_ref ( ) {
2151+ const VALUE : & i32 = & 1 ;
2152+ const SLICE : & [ i32 ] = core:: slice:: from_ref ( VALUE ) ;
2153+
2154+ assert ! ( core:: ptr:: eq( VALUE , & SLICE [ 0 ] ) )
2155+ }
2156+
21492157#[ test]
21502158fn test_slice_fill_with_uninit ( ) {
21512159 // This should not UB. See #87891
You can’t perform that action at this time.
0 commit comments