]> git.lizzy.rs Git - rust.git/blob - src/test/ui/consts/issue-66693.rs
Rollup merge of #99479 - Enselic:import-can-be-without-id, r=camelid
[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 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     //~| ERROR: erroneous constant used [const_err]
14     //~| WARNING: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
15 }
16
17 // ensure that conforming panics don't cause an error
18 const _: () = panic!();
19 static _BAR: () = panic!("panic in static");
20
21 const fn _bar() {
22     panic!("panic in const fn");
23 }
24
25 fn main() {}