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.
Auto merge of rust-lang#119133 - scottmcm:assert-unchecked, r=thomcc
Add `hint::assert_unchecked` Libs-API expressed interest, modulo bikeshedding, in rust-lang/libs-team#315 (comment) I think that means this is good for nightly, since we can always rename it before stabilization. Tracking issue: rust-lang#119131
- Loading branch information
Showing
4 changed files
with
68 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#![feature(hint_assert_unchecked)] | ||
#![feature(const_hint_assert_unchecked)] | ||
|
||
const _: () = unsafe { | ||
let n = u32::MAX.count_ones(); | ||
std::hint::assert_unchecked(n < 32); //~ ERROR evaluation of constant value failed | ||
}; | ||
|
||
fn main() { | ||
} |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
error[E0080]: evaluation of constant value failed | ||
--> $DIR/const-assert-unchecked-ub.rs:6:5 | ||
| | ||
LL | std::hint::assert_unchecked(n < 32); | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `assume` called with `false` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0080`. |