Add a test to check that inline const is in required_consts

Suggested in
https://github.com/rust-lang/rust/issues/76001#issuecomment-1315975027
This commit is contained in:
Gary Guo 2022-11-15 23:06:53 +00:00
parent 0f7f6b7061
commit 26fe88fedb
2 changed files with 24 additions and 0 deletions

View File

@ -0,0 +1,13 @@
// build-fail
// compile-flags: -Zmir-opt-level=3
#![feature(inline_const)]
fn foo<T>() {
if false {
const { panic!() } //~ ERROR E0080
}
}
fn main() {
foo::<i32>();
}

View File

@ -0,0 +1,11 @@
error[E0080]: evaluation of `foo::<i32>::{constant#0}` failed
--> $DIR/required-const.rs:7:17
|
LL | const { panic!() }
| ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/required-const.rs:7:17
|
= note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info)
error: aborting due to previous error
For more information about this error, try `rustc --explain E0080`.