diff options
| author | Gary Guo <gary@garyguo.net> | 2022-11-15 23:06:53 +0000 |
|---|---|---|
| committer | Gary Guo <gary@garyguo.net> | 2023-08-18 17:07:07 +0100 |
| commit | 26fe88fedb19a4118d58a6e439709759f65c63c9 (patch) | |
| tree | 0b21f991ae7d268039a27818c5ebc5c46f8ed37e /tests | |
| parent | 0f7f6b70617fbcda9f73755fa9b560bfb0a588eb (diff) | |
| download | rust-26fe88fedb19a4118d58a6e439709759f65c63c9.tar.gz rust-26fe88fedb19a4118d58a6e439709759f65c63c9.zip | |
Add a test to check that inline const is in required_consts
Suggested in https://github.com/rust-lang/rust/issues/76001#issuecomment-1315975027
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/inline-const/required-const.rs | 13 | ||||
| -rw-r--r-- | tests/ui/inline-const/required-const.stderr | 11 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tests/ui/inline-const/required-const.rs b/tests/ui/inline-const/required-const.rs new file mode 100644 index 00000000000..0483410662b --- /dev/null +++ b/tests/ui/inline-const/required-const.rs @@ -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>(); +} diff --git a/tests/ui/inline-const/required-const.stderr b/tests/ui/inline-const/required-const.stderr new file mode 100644 index 00000000000..d6948e7acc0 --- /dev/null +++ b/tests/ui/inline-const/required-const.stderr @@ -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`. |
