File tree 2 files changed +21
-3
lines changed
src/test/ui/consts/miri_unleashed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,14 @@ static CMP: () = {
11
11
//~| "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
12
12
} ;
13
13
14
- static INT_PTR_ARITH : ( ) = unsafe {
14
+ static PTR_INT_CAST : ( ) = {
15
+ let x = & 0 as * const _ as usize ;
16
+ //~^ ERROR could not evaluate static initializer
17
+ //~| unable to turn pointer into raw bytes
18
+ let _v = x == x;
19
+ } ;
20
+
21
+ static PTR_INT_TRANSMUTE : ( ) = unsafe {
15
22
let x: usize = std:: mem:: transmute ( & 0 ) ;
16
23
let _v = x + 0 ;
17
24
//~^ ERROR could not evaluate static initializer
Original file line number Diff line number Diff line change @@ -5,7 +5,13 @@ LL | let _v = x == x;
5
5
| ^^^^^^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
6
6
7
7
error[E0080]: could not evaluate static initializer
8
- --> $DIR/ptr_arith.rs:16:14
8
+ --> $DIR/ptr_arith.rs:15:13
9
+ |
10
+ LL | let x = &0 as *const _ as usize;
11
+ | ^^^^^^^^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes
12
+
13
+ error[E0080]: could not evaluate static initializer
14
+ --> $DIR/ptr_arith.rs:23:14
9
15
|
10
16
LL | let _v = x + 0;
11
17
| ^^^^^ unable to turn pointer into raw bytes
@@ -17,7 +23,12 @@ help: skipping check that does not even have a feature gate
17
23
|
18
24
LL | let _v = x == x;
19
25
| ^^^^^^
26
+ help: skipping check that does not even have a feature gate
27
+ --> $DIR/ptr_arith.rs:15:13
28
+ |
29
+ LL | let x = &0 as *const _ as usize;
30
+ | ^^^^^^^^^^^^^^^^^^^^^^^
20
31
21
- error: aborting due to 2 previous errors; 1 warning emitted
32
+ error: aborting due to 3 previous errors; 1 warning emitted
22
33
23
34
For more information about this error, try `rustc --explain E0080`.
You can’t perform that action at this time.
0 commit comments