]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/issue-66693.rs
Rollup merge of #87596 - jesyspa:issue-87318-hidden-whitespace, r=estebank
[rust.git] / src / test / ui / consts / issue-66693.rs
1 // Tests that the compiler does not ICE when const-evaluating a `panic!()` invocation with a
2 // non-`&str` argument.
3
4 #![feature(const_panic)]
5
6 const _: () = panic!(1);
7 //~^ ERROR: argument to `panic!()` in a const context must have type `&str`
8
9 static _FOO: () = panic!(true);
10 //~^ ERROR: argument to `panic!()` in a const context must have type `&str`
11
12 const fn _foo() {
13     panic!(&1); //~ ERROR: argument to `panic!()` in a const context must have type `&str`
14 }
15
16 // ensure that conforming panics don't cause an error
17 const _: () = panic!();
18 static _BAR: () = panic!("panic in static");
19
20 const fn _bar() {
21     panic!("panic in const fn");
22 }
23
24 fn main() {}