File tree 2 files changed +50
-0
lines changed
src/test/ui/consts/miri_unleashed
2 files changed +50
-0
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags: -Zunleash-the-miri-inside-of-you
2
+ // run-pass
3
+
4
+ const fn init ( buf : & mut [ u8 ; 1024 ] ) {
5
+ buf[ 33 ] = 3 ;
6
+ buf[ 444 ] = 4 ;
7
+ }
8
+
9
+ const fn nrvo ( init : fn ( & mut [ u8 ; 1024 ] ) ) -> [ u8 ; 1024 ] {
10
+ let mut buf = [ 0 ; 1024 ] ;
11
+ init ( & mut buf) ;
12
+ buf
13
+ }
14
+
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) ;
18
+
19
+ fn main ( ) {
20
+ assert_eq ! ( BUF [ 33 ] , 3 ) ;
21
+ assert_eq ! ( BUF [ 19 ] , 0 ) ;
22
+ assert_eq ! ( BUF [ 444 ] , 4 ) ;
23
+ }
Original file line number Diff line number Diff line change
1
+ warning: skipping const checks
2
+ |
3
+ help: skipping check for `const_mut_refs` feature
4
+ --> $DIR/nrvo.rs:5:5
5
+ |
6
+ LL | buf[33] = 3;
7
+ | ^^^^^^^^^^^
8
+ help: skipping check for `const_mut_refs` feature
9
+ --> $DIR/nrvo.rs:6:5
10
+ |
11
+ LL | buf[444] = 4;
12
+ | ^^^^^^^^^^^^
13
+ help: skipping check for `const_mut_refs` feature
14
+ --> $DIR/nrvo.rs:11:10
15
+ |
16
+ LL | init(&mut buf);
17
+ | ^^^^^^^^
18
+ help: skipping check that does not even have a feature gate
19
+ --> $DIR/nrvo.rs:11:5
20
+ |
21
+ LL | init(&mut buf);
22
+ | ^^^^^^^^^^^^^^
23
+
24
+ error: `-Zunleash-the-miri-inside-of-you` may not be used to circumvent feature gates, except when testing error paths in the CTFE engine
25
+
26
+ error: aborting due to previous error; 1 warning emitted
27
+
You can’t perform that action at this time.
0 commit comments