]> git.lizzy.rs Git - rust.git/blob - tests/ui/consts/issue-66693.rs
Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuviper
[rust.git] / tests / 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 const _: () = panic!(1);
5 //~^ ERROR: argument to `panic!()` in a const context must have type `&str`
6
7 static _FOO: () = panic!(true);
8 //~^ ERROR: argument to `panic!()` in a const context must have type `&str`
9
10 const fn _foo() {
11     panic!(&1);
12     //~^ ERROR: argument to `panic!()` in a const context must have type `&str`
13 }
14
15 // ensure that conforming panics don't cause an error
16 const _: () = panic!();
17 static _BAR: () = panic!("panic in static");
18
19 const fn _bar() {
20     panic!("panic in const fn");
21 }
22
23 fn main() {}