-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Make const panic!("..") work in Rust 2021. #86998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f827d3e
91d0823
76cf1b8
b64c4f9
b48274f
38bf5b0
4e63561
0b8033a
312bf8e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// edition:2021 | ||
#![feature(const_panic)] | ||
#![crate_type = "lib"] | ||
|
||
const A: () = std::panic!("blåhaj"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So... if my understanding is right, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oof, our test suite is really subpar. We have zero tests for const FOO: () = {
let mut x = [4, 2];
for i in 0..x.len() {
x[i] = x[i] + b'0';
}
let z = unsafe { std::str::from_utf8_unchecked(&x) };
panic!("{}", z);
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Nope. I want to make a next PR that makes |
||
//~^ ERROR evaluation of constant value failed | ||
|
||
const B: () = std::panic!(); | ||
//~^ ERROR evaluation of constant value failed | ||
|
||
const C: () = std::unreachable!(); | ||
//~^ ERROR evaluation of constant value failed | ||
|
||
const D: () = std::unimplemented!(); | ||
//~^ ERROR evaluation of constant value failed | ||
|
||
const E: () = core::panic!("shark"); | ||
//~^ ERROR evaluation of constant value failed | ||
|
||
const F: () = core::panic!(); | ||
//~^ ERROR evaluation of constant value failed | ||
|
||
const G: () = core::unreachable!(); | ||
//~^ ERROR evaluation of constant value failed | ||
|
||
const H: () = core::unimplemented!(); | ||
//~^ ERROR evaluation of constant value failed |
Uh oh!
There was an error while loading. Please reload this page.