File tree Expand file tree Collapse file tree 2 files changed +8
-32
lines changed Expand file tree Collapse file tree 2 files changed +8
-32
lines changed Original file line number Diff line number Diff line change 1- // compile-flags: -Zunleash-the-miri-inside-of-you
21// run-pass
32
3+ // When the NRVO is applied, the return place (`_0`) gets treated like a normal local. For example,
4+ // its address may be taken and it may be written to indirectly. Ensure that MIRI can handle this.
5+
6+ #![ feature( const_mut_refs) ]
7+
8+ #[ inline( never) ] // Try to ensure that MIR optimizations don't optimize this away.
49const fn init ( buf : & mut [ u8 ; 1024 ] ) {
510 buf[ 33 ] = 3 ;
611 buf[ 444 ] = 4 ;
712}
813
9- const fn nrvo ( init : fn ( & mut [ u8 ; 1024 ] ) ) -> [ u8 ; 1024 ] {
14+ const fn nrvo ( ) -> [ u8 ; 1024 ] {
1015 let mut buf = [ 0 ; 1024 ] ;
1116 init ( & mut buf) ;
1217 buf
1318}
1419
15- // When the NRVO is applied, the return place (`_0`) gets treated like a normal local. For example,
16- // its address may be taken and it may be written to indirectly. Ensure that MIRI can handle this.
17- const BUF : [ u8 ; 1024 ] = nrvo ( init) ;
20+ const BUF : [ u8 ; 1024 ] = nrvo ( ) ;
1821
1922fn main ( ) {
2023 assert_eq ! ( BUF [ 33 ] , 3 ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments