Skip to content

Commit c3ea64c

Browse files
committed
Add tests for const_panic_extra gate
1 parent b34112c commit c3ea64c

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#![allow(non_fmt_panics)]
2+
#![feature(const_panic_extra)]
3+
#![crate_type = "lib"]
4+
5+
const _: () = core::panic!("hello {}", "world");
6+
//~^ ERROR evaluation of constant value failed
7+
8+
const _: () = core::panic!("answer is {ans}", ans = 21*2);
9+
//~^ ERROR evaluation of constant value failed
10+
11+
const _: () = core::assert_eq!(42, 43);
12+
//~^ ERROR evaluation of constant value failed
13+
14+
const _: () = core::assert_ne!(42, 42, "hello {}", "world");
15+
//~^ ERROR evaluation of constant value failed
16+
17+
const _: () = core::panic!("{}", 42);
18+
//~^ ERROR evaluation of constant value failed
19+
20+
const _: () = std::panic!(42);
21+
//~^ ERROR evaluation of constant value failed
22+
23+
const _: () = std::panic!(String::new());
24+
//~^ ERROR evaluation of constant value failed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
error[E0080]: evaluation of constant value failed
2+
--> $DIR/const_panic_extra.rs:5:15
3+
|
4+
LL | const _: () = core::panic!("hello {}", "world");
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'hello world', $DIR/const_panic_extra.rs:5:15
6+
|
7+
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error[E0080]: evaluation of constant value failed
10+
--> $DIR/const_panic_extra.rs:8:15
11+
|
12+
LL | const _: () = core::panic!("answer is {ans}", ans = 21*2);
13+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'answer is 42', $DIR/const_panic_extra.rs:8:15
14+
|
15+
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
16+
17+
error[E0080]: evaluation of constant value failed
18+
--> $DIR/const_panic_extra.rs:11:15
19+
|
20+
LL | const _: () = core::assert_eq!(42, 43);
21+
| ^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: `(left == right)`
22+
left: `42`,
23+
right: `43`', $DIR/const_panic_extra.rs:11:15
24+
|
25+
= note: this error originates in the macro `core::assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info)
26+
27+
error[E0080]: evaluation of constant value failed
28+
--> $DIR/const_panic_extra.rs:14:15
29+
|
30+
LL | const _: () = core::assert_ne!(42, 42, "hello {}", "world");
31+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: `(left != right)`
32+
left: `42`,
33+
right: `42`: hello world', $DIR/const_panic_extra.rs:14:15
34+
|
35+
= note: this error originates in the macro `core::assert_ne` (in Nightly builds, run with -Z macro-backtrace for more info)
36+
37+
error[E0080]: evaluation of constant value failed
38+
--> $DIR/const_panic_extra.rs:17:15
39+
|
40+
LL | const _: () = core::panic!("{}", 42);
41+
| ^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at '42', $DIR/const_panic_extra.rs:17:15
42+
|
43+
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
44+
45+
error[E0080]: evaluation of constant value failed
46+
--> $DIR/const_panic_extra.rs:20:15
47+
|
48+
LL | const _: () = std::panic!(42);
49+
| ^^^^^^^^^^^^^^^ the evaluated program panicked at 'Box<dyn Any>', $DIR/const_panic_extra.rs:20:15
50+
|
51+
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
52+
53+
error[E0080]: evaluation of constant value failed
54+
--> $DIR/const_panic_extra.rs:23:15
55+
|
56+
LL | const _: () = std::panic!(String::new());
57+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at '', $DIR/const_panic_extra.rs:23:15
58+
|
59+
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
60+
61+
error: aborting due to 7 previous errors
62+
63+
For more information about this error, try `rustc --explain E0080`.

0 commit comments

Comments
 (0)