forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#71500 - josephlr:offset, r=oli-obk,RalfJung
Make pointer offset methods/intrinsics const Implements rust-lang#71499 using [the implementations from miri](https://github.com/rust-lang/miri/blob/52f5d202bdcfe8986f0615845f8d1647ab8a2c6a/src/shims/intrinsics.rs#L96-L112). I added some tests what's allowed and what's UB. Let me know if any other cases should be added. CC: @RalfJung @oli-obk
- Loading branch information
Showing
13 changed files
with
424 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,28 @@ | ||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/ptr_arith.rs:10:14 | ||
--> $DIR/ptr_arith.rs:9:14 | ||
| | ||
LL | let _v = x == x; | ||
| ^^^^^^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants | ||
|
||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/ptr_arith.rs:17:14 | ||
--> $DIR/ptr_arith.rs:16:14 | ||
| | ||
LL | let _v = x + 0; | ||
| ^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants | ||
|
||
error[E0080]: could not evaluate static initializer | ||
--> $DIR/ptr_arith.rs:24:14 | ||
| | ||
LL | let _v = core::intrinsics::offset(x, 0); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ "calling intrinsic `offset`" needs an rfc before being allowed inside constants | ||
|
||
warning: skipping const checks | ||
| | ||
help: skipping check for `const_compare_raw_pointers` feature | ||
--> $DIR/ptr_arith.rs:10:14 | ||
--> $DIR/ptr_arith.rs:9:14 | ||
| | ||
LL | let _v = x == x; | ||
| ^^^^^^ | ||
help: skipping check that does not even have a feature gate | ||
--> $DIR/ptr_arith.rs:16:20 | ||
--> $DIR/ptr_arith.rs:15:20 | ||
| | ||
LL | let x: usize = std::mem::transmute(&0); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
help: skipping check that does not even have a feature gate | ||
--> $DIR/ptr_arith.rs:24:14 | ||
| | ||
LL | let _v = core::intrinsics::offset(x, 0); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 3 previous errors; 1 warning emitted | ||
error: aborting due to 2 previous errors; 1 warning emitted | ||
|
||
For more information about this error, try `rustc --explain E0080`. |
Oops, something went wrong.