Skip to content

Commit 6b20f58

Browse files
committed
miri_unleached: We now allow offset in const fn
Signed-off-by: Joe Richey <joerichey@google.com>
1 parent 88a37a2 commit 6b20f58

File tree

2 files changed

+6
-25
lines changed

2 files changed

+6
-25
lines changed

src/test/ui/consts/miri_unleashed/ptr_arith.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22
#![feature(core_intrinsics)]
33
#![allow(const_err)]
44

5-
// A test demonstrating that we prevent doing even trivial
6-
// pointer arithmetic or comparison during CTFE.
5+
// During CTFE, we prevent pointer comparison and pointer-to-int casts.
76

87
static CMP: () = {
98
let x = &0 as *const _;
@@ -19,11 +18,4 @@ static INT_PTR_ARITH: () = unsafe {
1918
//~| NOTE pointer-to-integer cast
2019
};
2120

22-
static PTR_ARITH: () = unsafe {
23-
let x = &0 as *const _;
24-
let _v = core::intrinsics::offset(x, 0);
25-
//~^ ERROR could not evaluate static initializer
26-
//~| NOTE calling intrinsic `offset`
27-
};
28-
2921
fn main() {}
Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,28 @@
11
error[E0080]: could not evaluate static initializer
2-
--> $DIR/ptr_arith.rs:10:14
2+
--> $DIR/ptr_arith.rs:9:14
33
|
44
LL | let _v = x == x;
55
| ^^^^^^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants
66

77
error[E0080]: could not evaluate static initializer
8-
--> $DIR/ptr_arith.rs:17:14
8+
--> $DIR/ptr_arith.rs:16:14
99
|
1010
LL | let _v = x + 0;
1111
| ^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
1212

13-
error[E0080]: could not evaluate static initializer
14-
--> $DIR/ptr_arith.rs:24:14
15-
|
16-
LL | let _v = core::intrinsics::offset(x, 0);
17-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "calling intrinsic `offset`" needs an rfc before being allowed inside constants
18-
1913
warning: skipping const checks
2014
|
2115
help: skipping check for `const_compare_raw_pointers` feature
22-
--> $DIR/ptr_arith.rs:10:14
16+
--> $DIR/ptr_arith.rs:9:14
2317
|
2418
LL | let _v = x == x;
2519
| ^^^^^^
2620
help: skipping check that does not even have a feature gate
27-
--> $DIR/ptr_arith.rs:16:20
21+
--> $DIR/ptr_arith.rs:15:20
2822
|
2923
LL | let x: usize = std::mem::transmute(&0);
3024
| ^^^^^^^^^^^^^^^^^^^^^^^
31-
help: skipping check that does not even have a feature gate
32-
--> $DIR/ptr_arith.rs:24:14
33-
|
34-
LL | let _v = core::intrinsics::offset(x, 0);
35-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3625

37-
error: aborting due to 3 previous errors; 1 warning emitted
26+
error: aborting due to 2 previous errors; 1 warning emitted
3827

3928
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)