File tree 2 files changed +8
-32
lines changed
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
2
1
// run-pass
3
2
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.
4
9
const fn init ( buf : & mut [ u8 ; 1024 ] ) {
5
10
buf[ 33 ] = 3 ;
6
11
buf[ 444 ] = 4 ;
7
12
}
8
13
9
- const fn nrvo ( init : fn ( & mut [ u8 ; 1024 ] ) ) -> [ u8 ; 1024 ] {
14
+ const fn nrvo ( ) -> [ u8 ; 1024 ] {
10
15
let mut buf = [ 0 ; 1024 ] ;
11
16
init ( & mut buf) ;
12
17
buf
13
18
}
14
19
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 ( ) ;
18
21
19
22
fn main ( ) {
20
23
assert_eq ! ( BUF [ 33 ] , 3 ) ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments