summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/issue-66693.rs
blob: df45d01ec029953b4a1212ad24f588767e594583 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Tests that the compiler does not ICE when const-evaluating a `panic!()` invocation with a
// non-`&str` argument.

const _: () = panic!(1);
//~^ ERROR: argument to `panic!()` in a const context must have type `&str`

static _FOO: () = panic!(true);
//~^ ERROR: argument to `panic!()` in a const context must have type `&str`

const fn _foo() {
    panic!(&1);
    //~^ ERROR: argument to `panic!()` in a const context must have type `&str`
}

// ensure that conforming panics don't cause an error
const _: () = panic!();
static _BAR: () = panic!("panic in static");

const fn _bar() {
    panic!("panic in const fn");
}

fn main() {}