Skip to content

Commit 7130127

Browse files
committedOct 22, 2020
Add test for const panic!(CONST).
1 parent 4f7ffbf commit 7130127

File tree

2 files changed

+45
-17
lines changed

2 files changed

+45
-17
lines changed
 

‎src/test/ui/consts/const-eval/const_panic.rs

+8
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#![feature(const_panic)]
22
#![crate_type = "lib"]
33

4+
const MSG: &str = "hello";
5+
46
const Z: () = std::panic!("cheese");
57
//~^ ERROR any use of this value will cause an error
68

@@ -12,6 +14,9 @@ const Y: () = std::unreachable!();
1214

1315
const X: () = std::unimplemented!();
1416
//~^ ERROR any use of this value will cause an error
17+
//
18+
const W: () = std::panic!(MSG);
19+
//~^ ERROR any use of this value will cause an error
1520

1621
const Z_CORE: () = core::panic!("cheese");
1722
//~^ ERROR any use of this value will cause an error
@@ -24,3 +29,6 @@ const Y_CORE: () = core::unreachable!();
2429

2530
const X_CORE: () = core::unimplemented!();
2631
//~^ ERROR any use of this value will cause an error
32+
33+
const W_CORE: () = core::panic!(MSG);
34+
//~^ ERROR any use of this value will cause an error
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,103 @@
11
error: any use of this value will cause an error
2-
--> $DIR/const_panic.rs:4:15
2+
--> $DIR/const_panic.rs:6:15
33
|
44
LL | const Z: () = std::panic!("cheese");
55
| --------------^^^^^^^^^^^^^^^^^^^^^-
66
| |
7-
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:4:15
7+
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:6:15
88
|
99
= note: `#[deny(const_err)]` on by default
1010
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1111

1212
error: any use of this value will cause an error
13-
--> $DIR/const_panic.rs:7:16
13+
--> $DIR/const_panic.rs:9:16
1414
|
1515
LL | const Z2: () = std::panic!();
1616
| ---------------^^^^^^^^^^^^^-
1717
| |
18-
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:7:16
18+
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:9:16
1919
|
2020
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2121

2222
error: any use of this value will cause an error
23-
--> $DIR/const_panic.rs:10:15
23+
--> $DIR/const_panic.rs:12:15
2424
|
2525
LL | const Y: () = std::unreachable!();
2626
| --------------^^^^^^^^^^^^^^^^^^^-
2727
| |
28-
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:10:15
28+
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:12:15
2929
|
3030
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3131

3232
error: any use of this value will cause an error
33-
--> $DIR/const_panic.rs:13:15
33+
--> $DIR/const_panic.rs:15:15
3434
|
3535
LL | const X: () = std::unimplemented!();
3636
| --------------^^^^^^^^^^^^^^^^^^^^^-
3737
| |
38-
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:13:15
38+
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:15:15
3939
|
4040
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
4141

4242
error: any use of this value will cause an error
43-
--> $DIR/const_panic.rs:16:20
43+
--> $DIR/const_panic.rs:18:15
44+
|
45+
LL | const W: () = std::panic!(MSG);
46+
| --------------^^^^^^^^^^^^^^^^-
47+
| |
48+
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:18:15
49+
|
50+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
51+
52+
error: any use of this value will cause an error
53+
--> $DIR/const_panic.rs:21:20
4454
|
4555
LL | const Z_CORE: () = core::panic!("cheese");
4656
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
4757
| |
48-
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:16:20
58+
| the evaluated program panicked at 'cheese', $DIR/const_panic.rs:21:20
4959
|
5060
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
5161

5262
error: any use of this value will cause an error
53-
--> $DIR/const_panic.rs:19:21
63+
--> $DIR/const_panic.rs:24:21
5464
|
5565
LL | const Z2_CORE: () = core::panic!();
5666
| --------------------^^^^^^^^^^^^^^-
5767
| |
58-
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:19:21
68+
| the evaluated program panicked at 'explicit panic', $DIR/const_panic.rs:24:21
5969
|
6070
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
6171

6272
error: any use of this value will cause an error
63-
--> $DIR/const_panic.rs:22:20
73+
--> $DIR/const_panic.rs:27:20
6474
|
6575
LL | const Y_CORE: () = core::unreachable!();
6676
| -------------------^^^^^^^^^^^^^^^^^^^^-
6777
| |
68-
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:22:20
78+
| the evaluated program panicked at 'internal error: entered unreachable code', $DIR/const_panic.rs:27:20
6979
|
7080
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
7181

7282
error: any use of this value will cause an error
73-
--> $DIR/const_panic.rs:25:20
83+
--> $DIR/const_panic.rs:30:20
7484
|
7585
LL | const X_CORE: () = core::unimplemented!();
7686
| -------------------^^^^^^^^^^^^^^^^^^^^^^-
7787
| |
78-
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:25:20
88+
| the evaluated program panicked at 'not implemented', $DIR/const_panic.rs:30:20
89+
|
90+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
91+
92+
error: any use of this value will cause an error
93+
--> $DIR/const_panic.rs:33:20
94+
|
95+
LL | const W_CORE: () = core::panic!(MSG);
96+
| -------------------^^^^^^^^^^^^^^^^^-
97+
| |
98+
| the evaluated program panicked at 'hello', $DIR/const_panic.rs:33:20
7999
|
80100
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
81101

82-
error: aborting due to 8 previous errors
102+
error: aborting due to 10 previous errors
83103

0 commit comments

Comments
 (0)
Please sign in to comment.