Skip to content

Commit 9607b5c

Browse files
committed
Auto merge of rust-lang#80851 - m-ou-se:panic-2021, r=petrochenkov
Implement Rust 2021 panic This implements the Rust 2021 versions of `panic!()`. See rust-lang#80162 and rust-lang/rfcs#3007. It does so by replacing `{std, core}::panic!()` by a bulitin macro that expands to either `$crate::panic::panic_2015!(..)` or `$crate::panic::panic_2021!(..)` depending on the edition of the caller. This does not yet make std's panic an alias for core's panic on Rust 2021 as the RFC proposes. That will be a separate change: rust-lang@c5273bd That change is blocked on figuring out what to do with rust-lang#80846 first.
2 parents ac912be + 3a0ae08 commit 9607b5c

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

tests/ui/panicking_macros.stderr

+19-4
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,12 @@ error: `panic` should not be present in production code
1111
|
1212
LL | panic!("message");
1313
| ^^^^^^^^^^^^^^^^^^
14-
|
15-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
1614

1715
error: `panic` should not be present in production code
1816
--> $DIR/panicking_macros.rs:10:5
1917
|
2018
LL | panic!("{} {}", "panic with", "multiple arguments");
2119
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
22-
|
23-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
2420

2521
error: `todo` should not be present in production code
2622
--> $DIR/panicking_macros.rs:16:5
@@ -29,18 +25,23 @@ LL | todo!();
2925
| ^^^^^^^^
3026
|
3127
= note: `-D clippy::todo` implied by `-D warnings`
28+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3229

3330
error: `todo` should not be present in production code
3431
--> $DIR/panicking_macros.rs:17:5
3532
|
3633
LL | todo!("message");
3734
| ^^^^^^^^^^^^^^^^^
35+
|
36+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
3837

3938
error: `todo` should not be present in production code
4039
--> $DIR/panicking_macros.rs:18:5
4140
|
4241
LL | todo!("{} {}", "panic with", "multiple arguments");
4342
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43+
|
44+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
4445

4546
error: `unimplemented` should not be present in production code
4647
--> $DIR/panicking_macros.rs:24:5
@@ -49,18 +50,23 @@ LL | unimplemented!();
4950
| ^^^^^^^^^^^^^^^^^
5051
|
5152
= note: `-D clippy::unimplemented` implied by `-D warnings`
53+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
5254

5355
error: `unimplemented` should not be present in production code
5456
--> $DIR/panicking_macros.rs:25:5
5557
|
5658
LL | unimplemented!("message");
5759
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
60+
|
61+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
5862

5963
error: `unimplemented` should not be present in production code
6064
--> $DIR/panicking_macros.rs:26:5
6165
|
6266
LL | unimplemented!("{} {}", "panic with", "multiple arguments");
6367
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
68+
|
69+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
6470

6571
error: usage of the `unreachable!` macro
6672
--> $DIR/panicking_macros.rs:32:5
@@ -69,6 +75,7 @@ LL | unreachable!();
6975
| ^^^^^^^^^^^^^^^
7076
|
7177
= note: `-D clippy::unreachable` implied by `-D warnings`
78+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
7279

7380
error: usage of the `unreachable!` macro
7481
--> $DIR/panicking_macros.rs:33:5
@@ -83,6 +90,8 @@ error: usage of the `unreachable!` macro
8390
|
8491
LL | unreachable!("{} {}", "panic with", "multiple arguments");
8592
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
93+
|
94+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
8695

8796
error: `panic` should not be present in production code
8897
--> $DIR/panicking_macros.rs:40:5
@@ -95,18 +104,24 @@ error: `todo` should not be present in production code
95104
|
96105
LL | todo!();
97106
| ^^^^^^^^
107+
|
108+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
98109

99110
error: `unimplemented` should not be present in production code
100111
--> $DIR/panicking_macros.rs:42:5
101112
|
102113
LL | unimplemented!();
103114
| ^^^^^^^^^^^^^^^^^
115+
|
116+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
104117

105118
error: usage of the `unreachable!` macro
106119
--> $DIR/panicking_macros.rs:43:5
107120
|
108121
LL | unreachable!();
109122
| ^^^^^^^^^^^^^^^
123+
|
124+
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
110125

111126
error: aborting due to 16 previous errors
112127

0 commit comments

Comments
 (0)