mirror of https://github.com/rust-lang/rust.git
Auto merge of #80851 - m-ou-se:panic-2021, r=petrochenkov
Implement Rust 2021 panic
This implements the Rust 2021 versions of `panic!()`. See https://github.com/rust-lang/rust/issues/80162 and https://github.com/rust-lang/rfcs/pull/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: c5273bdfb2
That change is blocked on figuring out what to do with https://github.com/rust-lang/rust/issues/80846 first.
This commit is contained in:
commit
9607b5c6ac
|
@ -11,16 +11,12 @@ error: `panic` should not be present in production code
|
||||||
|
|
|
|
||||||
LL | panic!("message");
|
LL | panic!("message");
|
||||||
| ^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: `panic` should not be present in production code
|
error: `panic` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:10:5
|
--> $DIR/panicking_macros.rs:10:5
|
||||||
|
|
|
|
||||||
LL | panic!("{} {}", "panic with", "multiple arguments");
|
LL | panic!("{} {}", "panic with", "multiple arguments");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
||||||
|
|
||||||
error: `todo` should not be present in production code
|
error: `todo` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:16:5
|
--> $DIR/panicking_macros.rs:16:5
|
||||||
|
@ -29,18 +25,23 @@ LL | todo!();
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::todo` implied by `-D warnings`
|
= note: `-D clippy::todo` implied by `-D warnings`
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `todo` should not be present in production code
|
error: `todo` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:17:5
|
--> $DIR/panicking_macros.rs:17:5
|
||||||
|
|
|
|
||||||
LL | todo!("message");
|
LL | todo!("message");
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `todo` should not be present in production code
|
error: `todo` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:18:5
|
--> $DIR/panicking_macros.rs:18:5
|
||||||
|
|
|
|
||||||
LL | todo!("{} {}", "panic with", "multiple arguments");
|
LL | todo!("{} {}", "panic with", "multiple arguments");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `unimplemented` should not be present in production code
|
error: `unimplemented` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:24:5
|
--> $DIR/panicking_macros.rs:24:5
|
||||||
|
@ -49,18 +50,23 @@ LL | unimplemented!();
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::unimplemented` implied by `-D warnings`
|
= note: `-D clippy::unimplemented` implied by `-D warnings`
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `unimplemented` should not be present in production code
|
error: `unimplemented` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:25:5
|
--> $DIR/panicking_macros.rs:25:5
|
||||||
|
|
|
|
||||||
LL | unimplemented!("message");
|
LL | unimplemented!("message");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `unimplemented` should not be present in production code
|
error: `unimplemented` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:26:5
|
--> $DIR/panicking_macros.rs:26:5
|
||||||
|
|
|
|
||||||
LL | unimplemented!("{} {}", "panic with", "multiple arguments");
|
LL | unimplemented!("{} {}", "panic with", "multiple arguments");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: usage of the `unreachable!` macro
|
error: usage of the `unreachable!` macro
|
||||||
--> $DIR/panicking_macros.rs:32:5
|
--> $DIR/panicking_macros.rs:32:5
|
||||||
|
@ -69,6 +75,7 @@ LL | unreachable!();
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
|
||||||
= note: `-D clippy::unreachable` implied by `-D warnings`
|
= note: `-D clippy::unreachable` implied by `-D warnings`
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: usage of the `unreachable!` macro
|
error: usage of the `unreachable!` macro
|
||||||
--> $DIR/panicking_macros.rs:33:5
|
--> $DIR/panicking_macros.rs:33:5
|
||||||
|
@ -83,6 +90,8 @@ error: usage of the `unreachable!` macro
|
||||||
|
|
|
|
||||||
LL | unreachable!("{} {}", "panic with", "multiple arguments");
|
LL | unreachable!("{} {}", "panic with", "multiple arguments");
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `panic` should not be present in production code
|
error: `panic` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:40:5
|
--> $DIR/panicking_macros.rs:40:5
|
||||||
|
@ -95,18 +104,24 @@ error: `todo` should not be present in production code
|
||||||
|
|
|
|
||||||
LL | todo!();
|
LL | todo!();
|
||||||
| ^^^^^^^^
|
| ^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: `unimplemented` should not be present in production code
|
error: `unimplemented` should not be present in production code
|
||||||
--> $DIR/panicking_macros.rs:42:5
|
--> $DIR/panicking_macros.rs:42:5
|
||||||
|
|
|
|
||||||
LL | unimplemented!();
|
LL | unimplemented!();
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: usage of the `unreachable!` macro
|
error: usage of the `unreachable!` macro
|
||||||
--> $DIR/panicking_macros.rs:43:5
|
--> $DIR/panicking_macros.rs:43:5
|
||||||
|
|
|
|
||||||
LL | unreachable!();
|
LL | unreachable!();
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^
|
||||||
|
|
|
||||||
|
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||||
|
|
||||||
error: aborting due to 16 previous errors
|
error: aborting due to 16 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue