]> git.proxmox.com Git - rustc.git/blob - src/test/ui/consts/issue-66693.rs
New upstream version 1.57.0+dfsg1
[rustc.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 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); //~ ERROR: argument to `panic!()` in a const context must have type `&str`
12 }
13
14 // ensure that conforming panics don't cause an error
15 const _: () = panic!();
16 static _BAR: () = panic!("panic in static");
17
18 const fn _bar() {
19 panic!("panic in const fn");
20 }
21
22 fn main() {}