Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lint for panic!(123) which is not accepted in Rust 2021. #81645

Merged
merged 6 commits into from
Feb 5, 2021

Conversation

m-ou-se
Copy link
Member

@m-ou-se m-ou-se commented Feb 1, 2021

This extends the panic_fmt lint to warn for all cases where the first argument cannot be interpreted as a format string, as will happen in Rust 2021.

It suggests to add "{}", to format the message as a string. In the case of std::panic!(), it also suggests the recently stabilized
std::panic::panic_any() function as an alternative.

It renames the lint to non_fmt_panic to match the lint naming guidelines.

image

This is part of #80162.

r? @estebank

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 1, 2021
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
   Compiling gsgdt v0.1.2
error: panic message is not a string literal
  --> compiler/rustc_ast/src/mut_visit.rs:31:34
   |
31 |         assert!(self.len() == 1, err);
   |
   |
   = note: `-D non-fmt-panic` implied by `-D warnings`
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
31 |         assert!(self.len() == 1, "{}", err);

   Compiling rls-data v0.19.1
error: aborting due to previous error

@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 1, 2021

Ah, forgot to run the lint over rustc itself.

Well, looks like it's working then ^^

Copy link
Contributor

@estebank estebank left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code seems good, but I have one concern around backwards compat.

@@ -168,7 +168,7 @@ macro_rules! late_lint_passes {
ClashingExternDeclarations: ClashingExternDeclarations::new(),
DropTraitConstraints: DropTraitConstraints,
TemporaryCStringAsPtr: TemporaryCStringAsPtr,
PanicFmt: PanicFmt,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happens to PanicFmt?


cx.struct_span_lint(NON_FMT_PANIC, arg.span, |lint| {
let mut l = lint.build("panic message is not a string literal");
l.note("this is no longer accepted in Rust 2021");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we always mention the "edition" when talking about them: "Rust 2021 edition"

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There used to be a mix of "Rust 20xx" and "edition 20xx". As part of #79576 this was changed to consistently use "Rust 20xx" everywhere: c574ded

E.g.

struct_span_err!(diag, span, E0670, "`async fn` is not permitted in Rust 2015")
.span_label(span, "to use `async fn`, switch to Rust 2018 or later")

/// an `i32` as message.
///
/// Rust 2021 always interprets the first argument as format string.
NON_FMT_PANIC,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly concerned: we are changing the name of an existing lint. What will happen to anyone that has already used #![deny(fmt_panic)] or #![allow(fmt_panic)]?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That will show warning: unknown lint: `fmt_panic` . fmt_panic has only been there since .1.50, which is still in beta. I suppose we could also change the name there before it gets to stable. But I don't know how important this is. The lint does new things, so using the same name might also not be a great idea, as deny or allow will then deny or allow more things than before.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather we updated beta as well. The fact that the lint does more now is... well, we would be creating a new lint because we'd be having the same trade-offs, right?

Another alternative is to leave a "dead" fmt_panic lint that does nothing just as a placeholder...

We're close to a release. Would you mind taking over potentially changing the existing lint's name in beta?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 1, 2021

The change of the lint name was motivated by: #78088 (comment)

Not sure how to do this in a backwards-compatible way, or how much backwards compatibility matters for this lint.

@klensy
Copy link
Contributor

klensy commented Feb 1, 2021

Why not suggesting

panic!("123");

instead of

panic!("{}",123);

for some simple types?

@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 1, 2021

@klensy Because it's very uncommon for someone to literally have panic!(123) in their code. In almost all cases, this lint will trigger on panic!(some_variable). It's not worth it trying to special case integers like that.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
.................................................................................................... 7400/11332
............................................................................................i..ii... 7500/11332
............................................................ii...................................... 7600/11332
................................................................................i................... 7700/11332
................................................................i..................F.......FF....... 7800/11332
.....................F..................................i........................................... 7900/11332
.................................................................................................... 8100/11332
...................................i................................................................ 8200/11332
.................................................................................................... 8300/11332
....................................................i............................................... 8400/11332
---
51 
+ warning: panic message is not a string literal
+   --> $DIR/const_panic.rs:18:27
+    |
+ LL | const W: () = std::panic!(MSG);
+    |
+    |
+    = note: `#[warn(non_fmt_panic)]` on by default
+    = note: this is no longer accepted in Rust 2021
+ help: add a "{}" format string to Display the message
+    |
+ LL | const W: () = std::panic!("{}", MSG);
+    |                           ^^^^^
+ help: or use std::panic::panic_any instead
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
Some tests failed in compiletest suite=ui mode=ui host=x86_64-unknown-linux-gnu target=x86_64-unknown-linux-gnu
+ LL | const W: () = std::panic::panic_any(MSG);
+ 
+ 
52 error: any use of this value will cause an error
54    |

99    |
100    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
100    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
101 
- error: aborting due to 10 previous errors
+ warning: panic message is not a string literal
+   --> $DIR/const_panic.rs:33:33
+    |
+ LL | const W_CORE: () = core::panic!(MSG);
+    |
+    = note: this is no longer accepted in Rust 2021
+    = note: this is no longer accepted in Rust 2021
+ help: add a "{}" format string to Display the message
+    |
+ LL | const W_CORE: () = core::panic!("{}", MSG);
+ 
+ error: aborting due to 10 previous errors; 2 warnings emitted
103 
104 
104 


The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-eval/const_panic/const_panic.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args consts/const-eval/const_panic.rs`
error: 1 errors occurred comparing output.
status: exit code: 1
status: exit code: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/consts/const-eval/const_panic.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "--emit" "metadata" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-eval/const_panic" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/consts/const-eval/const_panic/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
error: any use of this value will cause an error
   |
   |
LL | const Z: () = std::panic!("cheese");
   |               |
   |               |
   |               the evaluated program panicked at 'cheese', /checkout/src/test/ui/consts/const-eval/const_panic.rs:6:15
   |
   = note: `#[deny(const_err)]` on by default
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
   |
   |
LL | const Z2: () = std::panic!();
   |                |
   |                the evaluated program panicked at 'explicit panic', /checkout/src/test/ui/consts/const-eval/const_panic.rs:9:16
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
   |
   |
LL | const Y: () = std::unreachable!();
   |               |
   |               |
   |               the evaluated program panicked at 'internal error: entered unreachable code', /checkout/src/test/ui/consts/const-eval/const_panic.rs:12:15
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: any use of this value will cause an error
   |
   |
LL | const X: () = std::unimplemented!();
   |               |
   |               |
   |               the evaluated program panicked at 'not implemented', /checkout/src/test/ui/consts/const-eval/const_panic.rs:15:15
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: any use of this value will cause an error
   |
   |
LL | const W: () = std::panic!(MSG);
   |               |
   |               |
   |               the evaluated program panicked at 'hello', /checkout/src/test/ui/consts/const-eval/const_panic.rs:18:15
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
  --> /checkout/src/test/ui/consts/const-eval/const_panic.rs:18:27
  --> /checkout/src/test/ui/consts/const-eval/const_panic.rs:18:27
   |
LL | const W: () = std::panic!(MSG);
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL | const W: () = std::panic!("{}", MSG);
   |                           ^^^^^
help: or use std::panic::panic_any instead
   |
LL | const W: () = std::panic::panic_any(MSG);


error: any use of this value will cause an error
   |
   |
LL | const Z_CORE: () = core::panic!("cheese");
   |                    |
   |                    |
   |                    the evaluated program panicked at 'cheese', /checkout/src/test/ui/consts/const-eval/const_panic.rs:21:20
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: any use of this value will cause an error
   |
   |
LL | const Z2_CORE: () = core::panic!();
   |                     |
   |                     the evaluated program panicked at 'explicit panic', /checkout/src/test/ui/consts/const-eval/const_panic.rs:24:21
   |
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: any use of this value will cause an error
   |
   |
LL | const Y_CORE: () = core::unreachable!();
   |                    |
   |                    |
   |                    the evaluated program panicked at 'internal error: entered unreachable code', /checkout/src/test/ui/consts/const-eval/const_panic.rs:27:20
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: any use of this value will cause an error
   |
   |
LL | const X_CORE: () = core::unimplemented!();
   |                    |
   |                    |
   |                    the evaluated program panicked at 'not implemented', /checkout/src/test/ui/consts/const-eval/const_panic.rs:30:20
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: any use of this value will cause an error
   |
   |
LL | const W_CORE: () = core::panic!(MSG);
   |                    |
   |                    |
   |                    the evaluated program panicked at 'hello', /checkout/src/test/ui/consts/const-eval/const_panic.rs:33:20
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: panic message is not a string literal
  --> /checkout/src/test/ui/consts/const-eval/const_panic.rs:33:33
  --> /checkout/src/test/ui/consts/const-eval/const_panic.rs:33:33
   |
LL | const W_CORE: () = core::panic!(MSG);
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL | const W_CORE: () = core::panic!("{}", MSG);

error: aborting due to 10 previous errors; 2 warnings emitted


---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/dynamic-drop.rs:49:20
   |
LL |             panic!(InjectedFailure);
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |             panic!("{}", InjectedFailure);
   |                    ^^^^^
help: or use std::panic::panic_any instead
   |
LL |             std::panic::panic_any(InjectedFailure);

warning: panic message is not a string literal
  --> $DIR/dynamic-drop.rs:70:20
   |
   |
LL |             panic!(InjectedFailure);
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |             panic!("{}", InjectedFailure);
   |                    ^^^^^
help: or use std::panic::panic_any instead
   |
LL |             std::panic::panic_any(InjectedFailure);

warning: 2 warnings emitted





The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/drop/dynamic-drop/dynamic-drop.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args drop/dynamic-drop.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/drop/dynamic-drop.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/drop/dynamic-drop/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/drop/dynamic-drop/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/drop/dynamic-drop.rs:49:20
   |
LL |             panic!(InjectedFailure);
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |             panic!("{}", InjectedFailure);
   |                    ^^^^^
help: or use std::panic::panic_any instead
   |
LL |             std::panic::panic_any(InjectedFailure);

warning: panic message is not a string literal
  --> /checkout/src/test/ui/drop/dynamic-drop.rs:70:20
   |
   |
LL |             panic!(InjectedFailure);
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |             panic!("{}", InjectedFailure);
   |                    ^^^^^
help: or use std::panic::panic_any instead
   |
LL |             std::panic::panic_any(InjectedFailure);

warning: 2 warnings emitted


---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/dynamic-drop-async.rs:85:20
   |
LL |             panic!(InjectedFailure);
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |             panic!("{}", InjectedFailure);
   |                    ^^^^^
help: or use std::panic::panic_any instead
   |
LL |             std::panic::panic_any(InjectedFailure);

warning: 1 warning emitted





The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/drop/dynamic-drop-async/dynamic-drop-async.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args drop/dynamic-drop-async.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/drop/dynamic-drop-async.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/drop/dynamic-drop-async/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--edition=2018" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/drop/dynamic-drop-async/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/drop/dynamic-drop-async.rs:85:20
   |
LL |             panic!(InjectedFailure);
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |             panic!("{}", InjectedFailure);
   |                    ^^^^^
help: or use std::panic::panic_any instead
   |
LL |             std::panic::panic_any(InjectedFailure);

warning: 1 warning emitted


---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/assert-macro-owned.rs:6:20
   |
LL |     assert!(false, "test-assert-owned".to_string());
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     assert!(false, "{}", "test-assert-owned".to_string());

warning: 1 warning emitted





The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/assert-macro-owned/assert-macro-owned.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args macros/assert-macro-owned.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/macros/assert-macro-owned.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/assert-macro-owned/a" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/macros/assert-macro-owned/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/macros/assert-macro-owned.rs:6:20
   |
LL |     assert!(false, "test-assert-owned".to_string());
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     assert!(false, "{}", "test-assert-owned".to_string());

warning: 1 warning emitted


---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/mir_drop_order.rs:41:43
   |
LL |         (d(4), &d(5), d(6), &d(7), panic!(InjectedFailure));
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |         (d(4), &d(5), d(6), &d(7), panic!("{}", InjectedFailure));
   |                                           ^^^^^
help: or use std::panic::panic_any instead
   |
LL |         (d(4), &d(5), d(6), &d(7), std::panic::panic_any(InjectedFailure));

warning: 1 warning emitted





The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mir/mir_drop_order/mir_drop_order.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args mir/mir_drop_order.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/mir/mir_drop_order.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mir/mir_drop_order/a" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/mir/mir_drop_order/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/mir/mir_drop_order.rs:41:43
   |
LL |         (d(4), &d(5), d(6), &d(7), panic!(InjectedFailure));
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |         (d(4), &d(5), d(6), &d(7), panic!("{}", InjectedFailure));
   |                                           ^^^^^
help: or use std::panic::panic_any instead
   |
LL |         (d(4), &d(5), d(6), &d(7), std::panic::panic_any(InjectedFailure));

warning: 1 warning emitted


---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/explicit-panic-msg.rs:13:12
   |
LL |     panic!(format!("woooo{}", "o"));
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021

warning: 1 warning emitted





The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/explicit-panic-msg/explicit-panic-msg.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args panics/explicit-panic-msg.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/panics/explicit-panic-msg.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/explicit-panic-msg/a" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/explicit-panic-msg/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/panics/explicit-panic-msg.rs:13:12
   |
LL |     panic!(format!("woooo{}", "o"));
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021

warning: 1 warning emitted


---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/panic-macro-any-wrapped.rs:6:12
   |
LL |     panic!(Box::new(612_i64));
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     panic!("{}", Box::new(612_i64));
   |            ^^^^^
help: or use std::panic::panic_any instead
   |
LL |     std::panic::panic_any(Box::new(612_i64));

warning: 1 warning emitted





The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/panic-macro-any-wrapped/panic-macro-any-wrapped.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args panics/panic-macro-any-wrapped.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/panics/panic-macro-any-wrapped.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/panic-macro-any-wrapped/a" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/panic-macro-any-wrapped/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/panics/panic-macro-any-wrapped.rs:6:12
   |
LL |     panic!(Box::new(612_i64));
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     panic!("{}", Box::new(612_i64));
   |            ^^^^^
help: or use std::panic::panic_any instead
   |
LL |     std::panic::panic_any(Box::new(612_i64));

warning: 1 warning emitted


---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/panic-macro-any.rs:8:12
   |
LL |     panic!(box 413 as Box<dyn std::any::Any + Send>);
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     panic!("{}", box 413 as Box<dyn std::any::Any + Send>);
   |            ^^^^^
help: or use std::panic::panic_any instead
   |
LL |     std::panic::panic_any(box 413 as Box<dyn std::any::Any + Send>);

warning: 1 warning emitted





The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/panic-macro-any/panic-macro-any.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args panics/panic-macro-any.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/panics/panic-macro-any.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/panic-macro-any/a" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/panic-macro-any/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/panics/panic-macro-any.rs:8:12
   |
LL |     panic!(box 413 as Box<dyn std::any::Any + Send>);
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     panic!("{}", box 413 as Box<dyn std::any::Any + Send>);
   |            ^^^^^
help: or use std::panic::panic_any instead
   |
LL |     std::panic::panic_any(box 413 as Box<dyn std::any::Any + Send>);

warning: 1 warning emitted


---
  --> $DIR/while-panic.rs:8:12
   |
LL |       panic!({
   |  ____________^
LL | |         while true {
LL | |             panic!("giraffe")
LL | |         }
LL | |         "clandestine"
LL | |     });
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     panic!("{}", {
   |            ^^^^^
help: or use std::panic::panic_any instead
LL |     std::panic::panic_any({
   |     ^^^^^^^^^^^^^^^^^^^^^^

warning: 1 warning emitted
warning: 1 warning emitted




The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/while-panic/while-panic.stderr
To update references, rerun the tests and pass the `--bless` flag
To only update this specific test, also pass `--test-args panics/while-panic.rs`
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/panics/while-panic.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Zemit-future-incompat-report" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/while-panic/a" "-A" "unused" "-Crpath" "-O" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/panics/while-panic/auxiliary"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
warning: panic message is not a string literal
  --> /checkout/src/test/ui/panics/while-panic.rs:8:12
   |
LL |       panic!({
   |  ____________^
LL | |         while true {
LL | |             panic!("giraffe")
LL | |         }
LL | |         "clandestine"
LL | |     });
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     panic!("{}", {
   |            ^^^^^
help: or use std::panic::panic_any instead
LL |     std::panic::panic_any({
   |     ^^^^^^^^^^^^^^^^^^^^^^

warning: 1 warning emitted
---
test result: FAILED. 11235 passed; 9 failed; 88 ignored; 0 measured; 0 filtered out; finished in 137.44s



command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--suite" "ui" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-9/bin/FileCheck" "--nodejs" "/usr/bin/node" "--host-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -O -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python3" "--lldb-python" "/usr/bin/python3" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "9.0.0" "--llvm-components" "aarch64 aarch64asmparser aarch64codegen aarch64desc aarch64disassembler aarch64info aarch64utils aggressiveinstcombine all all-targets amdgpu amdgpuasmparser amdgpucodegen amdgpudesc amdgpudisassembler amdgpuinfo amdgpuutils analysis arm armasmparser armcodegen armdesc armdisassembler arminfo armutils asmparser asmprinter avr avrasmparser avrcodegen avrdesc avrdisassembler avrinfo binaryformat bitreader bitstreamreader bitwriter bpf bpfasmparser bpfcodegen bpfdesc bpfdisassembler bpfinfo codegen core coroutines coverage debuginfocodeview debuginfodwarf debuginfogsym debuginfomsf debuginfopdb demangle dlltooldriver engine executionengine fuzzmutate globalisel hexagon hexagonasmparser hexagoncodegen hexagondesc hexagondisassembler hexagoninfo instcombine instrumentation interpreter ipo irreader jitlink lanai lanaiasmparser lanaicodegen lanaidesc lanaidisassembler lanaiinfo libdriver lineeditor linker lto mc mca mcdisassembler mcjit mcparser mips mipsasmparser mipscodegen mipsdesc mipsdisassembler mipsinfo mirparser msp430 msp430asmparser msp430codegen msp430desc msp430disassembler msp430info native nativecodegen nvptx nvptxcodegen nvptxdesc nvptxinfo objcarcopts object objectyaml option orcjit passes perfjitevents powerpc powerpcasmparser powerpccodegen powerpcdesc powerpcdisassembler powerpcinfo profiledata remarks riscv riscvasmparser riscvcodegen riscvdesc riscvdisassembler riscvinfo riscvutils runtimedyld scalaropts selectiondag sparc sparcasmparser sparccodegen sparcdesc sparcdisassembler sparcinfo support symbolize systemz systemzasmparser systemzcodegen systemzdesc systemzdisassembler systemzinfo tablegen target textapi transformutils vectorize webassembly webassemblyasmparser webassemblycodegen webassemblydesc webassemblydisassembler webassemblyinfo windowsmanifest x86 x86asmparser x86codegen x86desc x86disassembler x86info x86utils xcore xcorecodegen xcoredesc xcoredisassembler xcoreinfo xray" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap --stage 2 test --exclude src/tools/tidy
Build completed unsuccessfully in 0:15:20

@m-ou-se m-ou-se force-pushed the panic-lint branch 4 times, most recently from aab9a10 to 5f66fba Compare February 2, 2021 00:22
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 29 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiii

 finished in 0.069 seconds
Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
 finished in 9.687 seconds
Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 116 tests
iiiiiiiiii.i.i..i..i..ii....i..i...ii..........iiii.........i.....i...i.......ii.i.ii......iiii....i 100/116
test result: ok. 78 passed; 0 failed; 38 ignored; 0 measured; 0 filtered out; finished in 2.28s

 finished in 2.355 seconds
Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
---
.................................................................................................... 200/2831
..ii................................................................................................ 300/2831
...................................................i................................................ 400/2831
.................................................................................................... 500/2831
........................i..i...F..............iiii.................................................. 600/2831
.................................................................................................... 800/2831
.................................................................................................... 900/2831
.................................................................................................... 1000/2831
.................................................................................................... 1100/2831
---
---- src/lib.rs - panic (line 41) stdout ----
error: panic message is not a string literal
 --> src/lib.rs:45:8
  |
7 | panic!(4); // panic with the value of 4 to be collected elsewhere
  |
note: the lint level is defined here
 --> src/lib.rs:39:9
  |
  |
1 | #![deny(warnings)]
  |         ^^^^^^^^
  = note: `#[deny(non_fmt_panic)]` implied by `#[deny(warnings)]`
  = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
  |
7 | panic!("{}", 4); // panic with the value of 4 to be collected elsewhere
  |        ^^^^^
help: or use std::panic::panic_any instead
  |
7 | std::panic::panic_any(4); // panic with the value of 4 to be collected elsewhere

error: aborting due to previous error

Couldn't compile the test.
---

error: test failed, to rerun pass '--doc'


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "-p" "core" "--" "--quiet"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap --stage 2 test --exclude src/tools/tidy
Build completed unsuccessfully in 0:20:47

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
 finished in 0.436 seconds
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 29 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiii

 finished in 0.072 seconds
Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
 finished in 9.717 seconds
Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 116 tests
iiiiiiiiii.i.i..i..i..ii....i..i...ii..........iiii.........i.....i...i.......ii.i.ii.....iiii.....i 100/116
test result: ok. 78 passed; 0 failed; 38 ignored; 0 measured; 0 filtered out; finished in 2.33s

 finished in 2.403 seconds
Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
---
Set({"library/term"}) not skipped for "bootstrap::test::Crate" -- not in ["src/tools/tidy"]
 finished in 67.172 seconds
Testing term stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling term v0.0.0 (/checkout/library/term)
error: panic message is not a string literal
  --> library/term/src/terminfo/parm/tests.rs:80:30
   |
80 |         assert!(res.is_ok(), res.unwrap_err());
   |
   |
   = note: `-D non-fmt-panic` implied by `-D warnings`
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
80 |         assert!(res.is_ok(), "{}", res.unwrap_err());

error: panic message is not a string literal
error: panic message is not a string literal
  --> library/term/src/terminfo/parm/tests.rs:84:30
   |
84 |         assert!(res.is_ok(), res.unwrap_err());
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
84 |         assert!(res.is_ok(), "{}", res.unwrap_err());

error: panic message is not a string literal
error: panic message is not a string literal
  --> library/term/src/terminfo/parm/tests.rs:88:30
   |
88 |         assert!(res.is_ok(), res.unwrap_err());
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
88 |         assert!(res.is_ok(), "{}", res.unwrap_err());

error: panic message is not a string literal
error: panic message is not a string literal
  --> library/term/src/terminfo/parm/tests.rs:98:26
   |
98 |     assert!(res.is_ok(), res.unwrap_err());
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
98 |     assert!(res.is_ok(), "{}", res.unwrap_err());

error: panic message is not a string literal
error: panic message is not a string literal
   --> library/term/src/terminfo/parm/tests.rs:101:26
    |
101 |     assert!(res.is_ok(), res.unwrap_err());
    |
    = note: this is no longer accepted in Rust 2021
    = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
    |
101 |     assert!(res.is_ok(), "{}", res.unwrap_err());

error: panic message is not a string literal
error: panic message is not a string literal
   --> library/term/src/terminfo/parm/tests.rs:104:26
    |
104 |     assert!(res.is_ok(), res.unwrap_err());
    |
    = note: this is no longer accepted in Rust 2021
    = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
    |
104 |     assert!(res.is_ok(), "{}", res.unwrap_err());

error: aborting due to 6 previous errors

error: could not compile `term`
error: could not compile `term`

To learn more, run the command again with --verbose.


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "-p" "term" "--" "--quiet"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap --stage 2 test --exclude src/tools/tidy
Build completed unsuccessfully in 0:21:13

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-9 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
Suite("src/test/assembly") not skipped for "bootstrap::test::Assembly" -- not in ["src/tools/tidy"]
Check compiletest suite=assembly mode=assembly (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 29 tests
iiiiiiiiiiiiiiiiiiiiiiiiiiiii

 finished in 0.071 seconds
Suite("src/test/incremental") not skipped for "bootstrap::test::Incremental" -- not in ["src/tools/tidy"]
Check compiletest suite=incremental mode=incremental (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
Suite("src/test/debuginfo") not skipped for "bootstrap::test::Debuginfo" -- not in ["src/tools/tidy"]
Check compiletest suite=debuginfo mode=debuginfo (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)

running 116 tests
iiiiiiiiii.i.i..i..i..ii....i..i...ii..........iiii.........i.....i...i.......ii.i.ii.....iiii.....i 100/116
test result: ok. 78 passed; 0 failed; 38 ignored; 0 measured; 0 filtered out; finished in 2.36s

 finished in 2.433 seconds
Suite("src/test/ui-fulldeps") not skipped for "bootstrap::test::UiFullDeps" -- not in ["src/tools/tidy"]
---
   Compiling test v0.0.0 (/checkout/library/test)
error: panic message is not a string literal
   --> library/test/src/tests.rs:202:16
    |
202 |         panic!(1i32);
    |
    |
    = note: `-D non-fmt-panic` implied by `-D warnings`
    = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
    |
202 |         panic!("{}", 1i32);
    |                ^^^^^
help: or use std::panic::panic_any instead
    |
202 |         std::panic::panic_any(1i32);

error: aborting due to previous error

error: could not compile `test`
error: could not compile `test`

To learn more, run the command again with --verbose.


command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-Zbinary-dep-depinfo" "-j" "16" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/library/test/Cargo.toml" "-p" "test" "--" "--quiet"


failed to run: /checkout/obj/build/bootstrap/debug/bootstrap --stage 2 test --exclude src/tools/tidy
Build completed unsuccessfully in 0:22:43

@estebank
Copy link
Contributor

estebank commented Feb 2, 2021

@bors r+

@bors
Copy link
Contributor

bors commented Feb 2, 2021

📌 Commit 717355d has been approved by estebank

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 2, 2021
m-ou-se added a commit to m-ou-se/rust that referenced this pull request Feb 2, 2021
Add lint for `panic!(123)` which is not accepted in Rust 2021.

This extends the `panic_fmt` lint to warn for all cases where the first argument cannot be interpreted as a format string, as will happen in Rust 2021.

It suggests to add `"{}",` to format the message as a string. In the case of `std::panic!()`, it also suggests the recently stabilized
`std::panic::panic_any()` function as an alternative.

It renames the lint to `non_fmt_panic` to match the lint naming guidelines.

![image](https://user-images.githubusercontent.com/783247/106520928-675ea680-64d5-11eb-81f7-d8fa48b93a0b.png)

This is part of rust-lang#80162.

r? `@estebank`
@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 2, 2021

@bors r-

Failed in #81674 while testing clippy.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 2, 2021
@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 2, 2021

Changed an assert!(..., format!("...", ...)) to assert!(..., "...", ...) in clippy code to stop it from triggering this warning.

Waiting for the checks to complete, as (unlike before) the tools check is now being run as well:

Executing the job since clippy subtree was updated

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
  SCCACHE_BUCKET: rust-lang-ci-sccache2
  TOOLSTATE_REPO: https://github.com/rust-lang-nursery/rust-toolstate
  CACHE_DOMAIN: ci-caches.rust-lang.org
  EXTRA_VARIABLES: {
 "CI_ONLY_WHEN_SUBMODULES_CHANGED": 1
##[endgroup]
adding extra environment variable CI_ONLY_WHEN_SUBMODULES_CHANGED
linux builder detected, using docker to run the build
##[group]Run src/ci/scripts/should-skip-this.sh
---
   Compiling miri v0.1.0 (/checkout/src/tools/miri)
warning: panic message is not a string literal
   --> /checkout/library/alloc/src/macros.rs:111:23
    |
110 |  / macro_rules! format {
111 |  |     ($($arg:tt)*) => {{
    |  |_______________________^
112 | ||         let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));
113 | ||         res
114 | ||     }}
    | ||_____^
115 |  | }
    |  |_- in this expansion of `format!`
   ::: src/tools/miri/src/bin/miri.rs:233:32
    |
233 |                            panic!(format!(
    |  _________________________________-
    |  _________________________________-
234 | |                              "-Zmiri-seed must be at most 8 bytes, was {}",
235 | |                              seed_raw.len()
236 | |                          ));
    | |__________________________- in this macro invocation
    |
    = note: `#[warn(non_fmt_panic)]` on by default
    = note: this is no longer accepted in Rust 2021
warning: 1 warning emitted

    Finished release [optimized] target(s) in 1m 36s
Building stage2 tool cargo-miri (x86_64-unknown-linux-gnu)
---
   Compiling tester v0.7.0
warning: panic message is not a string literal
   --> /checkout/library/alloc/src/macros.rs:111:23
    |
110 |  / macro_rules! format {
111 |  |     ($($arg:tt)*) => {{
    |  |_______________________^
112 | ||         let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));
113 | ||         res
114 | ||     }}
    | ||_____^
115 |  | }
    |  |_- in this expansion of `format!`
   ::: src/tools/miri/src/bin/miri.rs:233:32
    |
233 |                            panic!(format!(
    |  _________________________________-
    |  _________________________________-
234 | |                              "-Zmiri-seed must be at most 8 bytes, was {}",
235 | |                              seed_raw.len()
236 | |                          ));
    | |__________________________- in this macro invocation
    |
    = note: `#[warn(non_fmt_panic)]` on by default
    = note: this is no longer accepted in Rust 2021
warning: 1 warning emitted

    Finished release [optimized] target(s) in 1m 12s
     Running build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/miri-d5f36d6a3f04a7a2
---
normalized stderr:
warning: panic message is not a string literal
  --> $DIR/catch_panic.rs:LL:38
   |
54 |     test(None, |old_val| std::panic!(format!("Hello from panic: {:?}", old_val)));
   |
   |
   = note: `#[warn(non_fmt_panic)]` on by default
   = note: this is no longer accepted in Rust 2021

warning: panic message is not a string literal
  --> $DIR/catch_panic.rs:LL:39
   |
   |
56 |     test(None, |_old_val| std::panic!(1337));
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
56 |     test(None, |_old_val| std::panic!("{}", 1337));
   |                                       ^^^^^
help: or use std::panic::panic_any instead
   |
56 |     test(None, |_old_val| std::panic::panic_any(1337));

warning: panic message is not a string literal
  --> $DIR/catch_panic.rs:LL:39
   |
   |
60 |     test(None, |old_val| core::panic!(&format!("Hello from panic: {:?}", old_val)));
   |
   = note: this is no longer accepted in Rust 2021
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
60 |     test(None, |old_val| core::panic!("{}", &format!("Hello from panic: {:?}", old_val)));

thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:LL:27
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Caught panic message (&str): Hello from panic: std
---

+warning: panic message is not a string literal
+  --> $DIR/catch_panic.rs:LL:38
+   |
+54 |     test(None, |old_val| std::panic!(format!("Hello from panic: {:?}", old_val)));
+   |
+   |
+   = note: `#[warn(non_fmt_panic)]` on by default
+   = note: this is no longer accepted in Rust 2021
+
+warning: panic message is not a string literal
+  --> $DIR/catch_panic.rs:LL:39
+   |
+   |
+56 |     test(None, |_old_val| std::panic!(1337));
+   |
+   = note: this is no longer accepted in Rust 2021
+   = note: this is no longer accepted in Rust 2021
+help: add a "{}" format string to Display the message
+   |
+56 |     test(None, |_old_val| std::panic!("{}", 1337));
+   |                                       ^^^^^
+help: or use std::panic::panic_any instead
+   |
+56 |     test(None, |_old_val| std::panic::panic_any(1337));
+
+warning: panic message is not a string literal
+  --> $DIR/catch_panic.rs:LL:39
+   |
+   |
+60 |     test(None, |old_val| core::panic!(&format!("Hello from panic: {:?}", old_val)));
+   |
+   = note: this is no longer accepted in Rust 2021
+   = note: this is no longer accepted in Rust 2021
+help: add a "{}" format string to Display the message
+   |
+60 |     test(None, |old_val| core::panic!("{}", &format!("Hello from panic: {:?}", old_val)));
+
 thread 'main' panicked at 'Hello from panic: std', $DIR/catch_panic.rs:LL:27
 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
 Caught panic message (&str): Hello from panic: std
---
 Success!
 

The actual stderr differed from the expected stderr.
Actual stderr saved to /tmp/compiletestSmvdcU/panic/catch_panic.stderr
To update references, run this command from build directory:
tests/run-pass/update-references.sh '/tmp/compiletestSmvdcU' 'panic/catch_panic.rs'
error: 1 errors occurred comparing output.
status: exit code: 0
status: exit code: 0
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/miri" "tests/run-pass/panic/catch_panic.rs" "-L" "/tmp/compiletestSmvdcU" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/tmp/compiletestSmvdcU/panic/catch_panic.stage-id" "-A" "unused" "--edition" "2018" "-Astable-features" "--sysroot" "/home/user/.cache/miri/HOST" "-Zmiri-symbolic-alignment-check" "-L" "/tmp/compiletestSmvdcU/panic/catch_panic.stage-id.aux"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
{"message":"panic message is not a string literal","code":{"code":"non_fmt_panic","explanation":null},"level":"warning","spans":[{"file_name":"/checkout/library/alloc/src/macros.rs","byte_start":3730,"byte_end":3830,"line_start":111,"line_end":114,"column_start":23,"column_end":6,"is_primary":true,"text":[{"text":"    ($($arg:tt)*) => {{","highlight_start":23,"highlight_end":24},{"text":"        let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));","highlight_start":1,"highlight_end":81},{"text":"        res","highlight_start":1,"highlight_end":12},{"text":"    }}","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/run-pass/panic/catch_panic.rs","byte_start":1678,"byte_end":1720,"line_start":54,"line_end":54,"column_start":38,"column_end":80,"is_primary":false,"text":[{"text":"    test(None, |old_val| std::panic!(format!(\"Hello from panic: {:?}\", old_val)));","highlight_start":38,"highlight_end":80}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"format!","def_site_span":{"file_name":"/checkout/library/alloc/src/macros.rs","byte_start":3686,"byte_end":3833,"line_start":110,"line_end":115,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! format {","highlight_start":1,"highlight_end":1},{"text":"    ($($arg:tt)*) => {{","highlight_start":1,"highlight_end":1},{"text":"        let res = $crate::fmt::format($crate::__export::format_args!($($arg)*));","highlight_start":1,"highlight_end":1},{"text":"        res","highlight_start":1,"highlight_end":1},{"text":"    }}","highlight_start":1,"highlight_end":1},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"`#[warn(non_fmt_panic)]` on by default","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"this is no longer accepted in Rust 2021","code":null,"level":"note","spans":[],"children":[],"rendered":null}],"rendered":"warning: panic message is not a string literal\n  --> tests/run-pass/panic/catch_panic.rs:54:38\n   |\n54 |     test(None, |old_val| std::panic!(format!(\"Hello from panic: {:?}\", old_val)));\n   |                                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: `#[warn(non_fmt_panic)]` on by default\n   = note: this is no longer accepted in Rust 2021\n   = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"panic message is not a string literal","code":{"code":"non_fmt_panic","explanation":null},"level":"warning","spans":[{"file_name":"tests/run-pass/panic/catch_panic.rs","byte_start":1836,"byte_end":1840,"line_start":56,"line_end":56,"column_start":39,"column_end":43,"is_primary":true,"text":[{"text":"    test(None, |_old_val| std::panic!(1337));","highlight_start":39,"highlight_end":43}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this is no longer accepted in Rust 2021","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add a \"{}\" format string to Display the message","code":null,"level":"help","spans":[{"file_name":"tests/run-pass/panic/catch_panic.rs","byte_start":1836,"byte_end":1836,"line_start":56,"line_end":56,"column_start":39,"column_end":39,"is_primary":true,"text":[{"text":"    test(None, |_old_val| std::panic!(1337));","highlight_start":39,"highlight_end":39}],"label":null,"suggested_replacement":"\"{}\", ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null},{"message":"or use std::panic::panic_any instead","code":null,"level":"help","spans":[{"file_name":"tests/run-pass/panic/catch_panic.rs","byte_start":1824,"byte_end":1836,"line_start":56,"line_end":56,"column_start":27,"column_end":39,"is_primary":true,"text":[{"text":"    test(None, |_old_val| std::panic!(1337));","highlight_start":27,"highlight_end":39}],"label":null,"suggested_replacement":"std::panic::panic_any(","suggestion_applicability":"MachineApplicable","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: panic message is not a string literal\n  --> tests/run-pass/panic/catch_panic.rs:56:39\n   |\n56 |     test(None, |_old_val| std::panic!(1337));\n   |                                       ^^^^\n   |\n   = note: this is no longer accepted in Rust 2021\nhelp: add a \"{}\" format string to Display the message\n   |\n56 |     test(None, |_old_val| std::panic!(\"{}\", 1337));\n   |                                       ^^^^^\nhelp: or use std::panic::panic_any instead\n   |\n56 |     test(None, |_old_val| std::panic::panic_any(1337));\n   |                           ^^^^^^^^^^^^^^^^^^^^^^\n\n"}
{"message":"panic message is not a string literal","code":{"code":"non_fmt_panic","explanation":null},"level":"warning","spans":[{"file_name":"tests/run-pass/panic/catch_panic.rs","byte_start":1969,"byte_end":2012,"line_start":60,"line_end":60,"column_start":39,"column_end":82,"is_primary":true,"text":[{"text":"    test(None, |old_val| core::panic!(&format!(\"Hello from panic: {:?}\", old_val)));","highlight_start":39,"highlight_end":82}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"this is no longer accepted in Rust 2021","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add a \"{}\" format string to Display the message","code":null,"level":"help","spans":[{"file_name":"tests/run-pass/panic/catch_panic.rs","byte_start":1969,"byte_end":1969,"line_start":60,"line_end":60,"column_start":39,"column_end":39,"is_primary":true,"text":[{"text":"    test(None, |old_val| core::panic!(&format!(\"Hello from panic: {:?}\", old_val)));","highlight_start":39,"highlight_end":39}],"label":null,"suggested_replacement":"\"{}\", ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"warning: panic message is not a string literal\n  --> tests/run-pass/panic/catch_panic.rs:60:39\n   |\n60 |     test(None, |old_val| core::panic!(&format!(\"Hello from panic: {:?}\", old_val)));\n   |                                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = note: this is no longer accepted in Rust 2021\nhelp: add a \"{}\" format string to Display the message\n   |\n60 |     test(None, |old_val| core::panic!(\"{}\", &format!(\"Hello from panic: {:?}\", old_val)));\n   |                                       ^^^^^\n\n"}
thread 'main' panicked at 'Hello from panic: std', tests/run-pass/panic/catch_panic.rs:53:27
Caught panic message (&str): Hello from panic: std
thread 'main' panicked at 'Hello from panic: 1', tests/run-pass/panic/catch_panic.rs:54:26
Caught panic message (String): Hello from panic: 1
thread 'main' panicked at 'Hello from panic: 2', tests/run-pass/panic/catch_panic.rs:55:26
---
failures:

---- compile_test stdout ----
normalized stderr:
error: `assert!(true)` will be optimized out by the compiler
   |
   |
LL |     assert!(true);
   |
   |
   = note: `-D clippy::assertions-on-constants` implied by `-D warnings`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: `assert!(false)` should probably be replaced
   |
   |
LL |     assert!(false);
   |
   |
   = help: use `panic!()` or `unreachable!()`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(true)` will be optimized out by the compiler
   |
   |
LL |     assert!(true, "true message");
   |
   = help: remove it
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: `assert!(false, "false message")` should probably be replaced
   |
   |
LL |     assert!(false, "false message");
   |
   |
   = help: use `panic!("false message")` or `unreachable!("false message")`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(false, msg.to_uppercase())` should probably be replaced
   |
   |
LL |     assert!(false, msg.to_uppercase());
   |
   |
   = help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(true)` will be optimized out by the compiler
   |
   |
LL |     assert!(B);
   |
   = help: remove it
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: `assert!(false)` should probably be replaced
   |
   |
LL |     assert!(C);
   |
   |
   = help: use `panic!()` or `unreachable!()`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(false, "C message")` should probably be replaced
   |
   |
LL |     assert!(C, "C message");
   |
   |
   = help: use `panic!("C message")` or `unreachable!("C message")`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `debug_assert!(true)` will be optimized out by the compiler
   |
   |
LL |     debug_assert!(true);
   |
   = help: remove it
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: panic message is not a string literal
  --> $DIR/assertions_on_constants.rs:15:20
   |
LL |     assert!(false, msg.to_uppercase());
   |
   |
   = note: `-D non-fmt-panic` implied by `-D warnings`
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |     assert!(false, "{}", msg.to_uppercase());

error: aborting due to 10 previous errors




expected stderr:
error: test failed, to rerun pass '--test compile-test'
error: `assert!(true)` will be optimized out by the compiler
   |
   |
LL |     assert!(true);
   |
   |
   = note: `-D clippy::assertions-on-constants` implied by `-D warnings`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: `assert!(false)` should probably be replaced
   |
   |
LL |     assert!(false);
   |
   |
   = help: use `panic!()` or `unreachable!()`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(true)` will be optimized out by the compiler
   |
   |
LL |     assert!(true, "true message");
   |
   = help: remove it
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: `assert!(false, "false message")` should probably be replaced
   |
   |
LL |     assert!(false, "false message");
   |
   |
   = help: use `panic!("false message")` or `unreachable!("false message")`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(false, msg.to_uppercase())` should probably be replaced
   |
   |
LL |     assert!(false, msg.to_uppercase());
   |
   |
   = help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(true)` will be optimized out by the compiler
   |
   |
LL |     assert!(B);
   |
   = help: remove it
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: `assert!(false)` should probably be replaced
   |
   |
LL |     assert!(C);
   |
   |
   = help: use `panic!()` or `unreachable!()`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(false, "C message")` should probably be replaced
   |
   |
LL |     assert!(C, "C message");
   |
   |
   = help: use `panic!("C message")` or `unreachable!("C message")`
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: `debug_assert!(true)` will be optimized out by the compiler
   |
   |
LL |     debug_assert!(true);
   |
   = help: remove it
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: aborting due to 9 previous errors



diff of stderr:

 error: `assert!(true)` will be optimized out by the compiler
    |
    |
 LL |     assert!(true);
    |
    |
    = note: `-D clippy::assertions-on-constants` implied by `-D warnings`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 
 error: `assert!(false)` should probably be replaced
    |
    |
 LL |     assert!(false);
    |
    |
    = help: use `panic!()` or `unreachable!()`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `assert!(true)` will be optimized out by the compiler
    |
    |
 LL |     assert!(true, "true message");
    |
    = help: remove it
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 
 error: `assert!(false, "false message")` should probably be replaced
    |
    |
 LL |     assert!(false, "false message");
    |
    |
    = help: use `panic!("false message")` or `unreachable!("false message")`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `assert!(false, msg.to_uppercase())` should probably be replaced
    |
    |
 LL |     assert!(false, msg.to_uppercase());
    |
    |
    = help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `assert!(true)` will be optimized out by the compiler
    |
    |
 LL |     assert!(B);
    |
    = help: remove it
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 
 error: `assert!(false)` should probably be replaced
    |
    |
 LL |     assert!(C);
    |
    |
    = help: use `panic!()` or `unreachable!()`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `assert!(false, "C message")` should probably be replaced
    |
    |
 LL |     assert!(C, "C message");
    |
    |
    = help: use `panic!("C message")` or `unreachable!("C message")`
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 error: `debug_assert!(true)` will be optimized out by the compiler
    |
    |
 LL |     debug_assert!(true);
    |
    = help: remove it
    = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
 
 
-error: aborting due to 9 previous errors
+error: panic message is not a string literal
+  --> $DIR/assertions_on_constants.rs:15:20
+   |
+LL |     assert!(false, msg.to_uppercase());
+   |
+   |
+   = note: `-D non-fmt-panic` implied by `-D warnings`
+   = note: this is no longer accepted in Rust 2021
+help: add a "{}" format string to Display the message
+   |
+LL |     assert!(false, "{}", msg.to_uppercase());
+
+error: aborting due to 10 previous errors
 
 
 

The actual stderr differed from the expected stderr.
Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-58613e8381df8652/out/test_build_base/assertions_on_constants.stderr
To update references, run this command from build directory:
tests/ui/update-references.sh '/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-58613e8381df8652/out/test_build_base' 'assertions_on_constants.rs'
error: 1 errors occurred comparing output.
status: exit code: 1
status: exit code: 1
command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools-bin/clippy-driver" "tests/ui/assertions_on_constants.rs" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-58613e8381df8652/out/test_build_base" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-C" "prefer-dynamic" "-o" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-58613e8381df8652/out/test_build_base/assertions_on_constants.stage-id" "-A" "unused" "--emit=metadata" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "-Dwarnings" "-Zui-testing" "--extern" "quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-45a3ec2898545ae5.rlib" "--extern" "serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-3e5755171965ca17.rlib" "--extern" "syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-efc540c81be69f24.rlib" "--extern" "clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-c43e08f62c64f186.rlib" "--extern" "regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-1bcf52e6f16bdb4f.rlib" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/clippy-58613e8381df8652/out/test_build_base/assertions_on_constants.stage-id.aux"
------------------------------------------

------------------------------------------
stderr:
stderr:
------------------------------------------
{"message":"`assert!(true)` will be optimized out by the compiler","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":135,"byte_end":149,"line_start":9,"line_end":9,"column_start":5,"column_end":19,"is_primary":true,"text":[{"text":"    assert!(true);","highlight_start":5,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":135,"byte_end":149,"line_start":9,"line_end":9,"column_start":5,"column_end":19,"is_primary":false,"text":[{"text":"    assert!(true);","highlight_start":5,"highlight_end":19}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":1},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":1},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":1},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"`-D clippy::assertions-on-constants` implied by `-D warnings`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"remove it","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(true)` will be optimized out by the compiler\n  --> tests/ui/assertions_on_constants.rs:9:5\n   |\nLL |     assert!(true);\n   |     ^^^^^^^^^^^^^^\n   |\n   = note: `-D clippy::assertions-on-constants` implied by `-D warnings`\n   = help: remove it\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`assert!(false)` should probably be replaced","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":154,"byte_end":169,"line_start":10,"line_end":10,"column_start":5,"column_end":20,"is_primary":true,"text":[{"text":"    assert!(false);","highlight_start":5,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":154,"byte_end":169,"line_start":10,"line_end":10,"column_start":5,"column_end":20,"is_primary":false,"text":[{"text":"    assert!(false);","highlight_start":5,"highlight_end":20}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"use `panic!()` or `unreachable!()`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(false)` should probably be replaced\n  --> tests/ui/assertions_on_constants.rs:10:5\n   |\nLL |     assert!(false);\n   |     ^^^^^^^^^^^^^^^\n   |\n   = help: use `panic!()` or `unreachable!()`\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`assert!(true)` will be optimized out by the compiler","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":174,"byte_end":204,"line_start":11,"line_end":11,"column_start":5,"column_end":35,"is_primary":true,"text":[{"text":"    assert!(true, \"true message\");","highlight_start":5,"highlight_end":35}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":174,"byte_end":204,"line_start":11,"line_end":11,"column_start":5,"column_end":35,"is_primary":false,"text":[{"text":"    assert!(true, \"true message\");","highlight_start":5,"highlight_end":35}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"remove it","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(true)` will be optimized out by the compiler\n  --> tests/ui/assertions_on_constants.rs:11:5\n   |\nLL |     assert!(true, \"true message\");\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: remove it\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`assert!(false, \"false message\")` should probably be replaced","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":209,"byte_end":241,"line_start":12,"line_end":12,"column_start":5,"column_end":37,"is_primary":true,"text":[{"text":"    assert!(false, \"false message\");","highlight_start":5,"highlight_end":37}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":209,"byte_end":241,"line_start":12,"line_end":12,"column_start":5,"column_end":37,"is_primary":false,"text":[{"text":"    assert!(false, \"false message\");","highlight_start":5,"highlight_end":37}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"use `panic!(\"false message\")` or `unreachable!(\"false message\")`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(false, \"false message\")` should probably be replaced\n  --> tests/ui/assertions_on_constants.rs:12:5\n   |\nLL |     assert!(false, \"false message\");\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: use `panic!(\"false message\")` or `unreachable!(\"false message\")`\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`assert!(false, msg.to_uppercase())` should probably be replaced","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":278,"byte_end":313,"line_start":15,"line_end":15,"column_start":5,"column_end":40,"is_primary":true,"text":[{"text":"    assert!(false, msg.to_uppercase());","highlight_start":5,"highlight_end":40}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":278,"byte_end":313,"line_start":15,"line_end":15,"column_start":5,"column_end":40,"is_primary":false,"text":[{"text":"    assert!(false, msg.to_uppercase());","highlight_start":5,"highlight_end":40}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(false, msg.to_uppercase())` should probably be replaced\n  --> tests/ui/assertions_on_constants.rs:15:5\n   |\nLL |     assert!(false, msg.to_uppercase());\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`assert!(true)` will be optimized out by the compiler","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":345,"byte_end":356,"line_start":18,"line_end":18,"column_start":5,"column_end":16,"is_primary":true,"text":[{"text":"    assert!(B);","highlight_start":5,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":345,"byte_end":356,"line_start":18,"line_end":18,"column_start":5,"column_end":16,"is_primary":false,"text":[{"text":"    assert!(B);","highlight_start":5,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"remove it","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(true)` will be optimized out by the compiler\n  --> tests/ui/assertions_on_constants.rs:18:5\n   |\nLL |     assert!(B);\n   |     ^^^^^^^^^^^\n   |\n   = help: remove it\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`assert!(false)` should probably be replaced","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":389,"byte_end":400,"line_start":21,"line_end":21,"column_start":5,"column_end":16,"is_primary":true,"text":[{"text":"    assert!(C);","highlight_start":5,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":389,"byte_end":400,"line_start":21,"line_end":21,"column_start":5,"column_end":16,"is_primary":false,"text":[{"text":"    assert!(C);","highlight_start":5,"highlight_end":16}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"use `panic!()` or `unreachable!()`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(false)` should probably be replaced\n  --> tests/ui/assertions_on_constants.rs:21:5\n   |\nLL |     assert!(C);\n   |     ^^^^^^^^^^^\n   |\n   = help: use `panic!()` or `unreachable!()`\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`assert!(false, \"C message\")` should probably be replaced","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":405,"byte_end":429,"line_start":22,"line_end":22,"column_start":5,"column_end":29,"is_primary":true,"text":[{"text":"    assert!(C, \"C message\");","highlight_start":5,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":405,"byte_end":429,"line_start":22,"line_end":22,"column_start":5,"column_end":29,"is_primary":false,"text":[{"text":"    assert!(C, \"C message\");","highlight_start":5,"highlight_end":29}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"use `panic!(\"C message\")` or `unreachable!(\"C message\")`","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `assert!(false, \"C message\")` should probably be replaced\n  --> tests/ui/assertions_on_constants.rs:22:5\n   |\nLL |     assert!(C, \"C message\");\n   |     ^^^^^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: use `panic!(\"C message\")` or `unreachable!(\"C message\")`\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"`debug_assert!(true)` will be optimized out by the compiler","code":{"code":"clippy::assertions_on_constants","explanation":null},"level":"error","spans":[{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":6461,"byte_end":6487,"line_start":184,"line_end":184,"column_start":59,"column_end":85,"is_primary":true,"text":[{"text":"    ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert!($($arg)*); })","highlight_start":59,"highlight_end":85}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":6461,"byte_end":6487,"line_start":184,"line_end":184,"column_start":59,"column_end":85,"is_primary":false,"text":[{"text":"    ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert!($($arg)*); })","highlight_start":59,"highlight_end":85}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":{"span":{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":435,"byte_end":455,"line_start":24,"line_end":24,"column_start":5,"column_end":25,"is_primary":false,"text":[{"text":"    debug_assert!(true);","highlight_start":5,"highlight_end":25}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null},"macro_decl_name":"debug_assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":6375,"byte_end":6492,"line_start":183,"line_end":185,"column_start":1,"column_end":2,"is_primary":false,"text":[{"text":"macro_rules! debug_assert {","highlight_start":1,"highlight_end":28},{"text":"    ($($arg:tt)*) => (if $crate::cfg!(debug_assertions) { $crate::assert!($($arg)*); })","highlight_start":1,"highlight_end":88},{"text":"}","highlight_start":1,"highlight_end":2}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}},"macro_decl_name":"$crate::assert!","def_site_span":{"file_name":"/checkout/library/core/src/macros/mod.rs","byte_start":41883,"byte_end":42039,"line_start":1238,"line_end":1241,"column_start":5,"column_end":6,"is_primary":false,"text":[{"text":"    macro_rules! assert {","highlight_start":5,"highlight_end":26},{"text":"        ($cond:expr $(,)?) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":61},{"text":"        ($cond:expr, $($arg:tt)+) => {{ /* compiler built-in */ }};","highlight_start":1,"highlight_end":68},{"text":"    }","highlight_start":1,"highlight_end":6}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}}}],"children":[{"message":"remove it","code":null,"level":"help","spans":[],"children":[],"rendered":null}],"rendered":"error: `debug_assert!(true)` will be optimized out by the compiler\n  --> tests/ui/assertions_on_constants.rs:24:5\n   |\nLL |     debug_assert!(true);\n   |     ^^^^^^^^^^^^^^^^^^^^\n   |\n   = help: remove it\n   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)\n\n"}
{"message":"panic message is not a string literal","code":{"code":"non_fmt_panic","explanation":null},"level":"error","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":293,"byte_end":311,"line_start":15,"line_end":15,"column_start":20,"column_end":38,"is_primary":true,"text":[{"text":"    assert!(false, msg.to_uppercase());","highlight_start":20,"highlight_end":38}],"label":null,"suggested_replacement":null,"suggestion_applicability":null,"expansion":null}],"children":[{"message":"`-D non-fmt-panic` implied by `-D warnings`","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"this is no longer accepted in Rust 2021","code":null,"level":"note","spans":[],"children":[],"rendered":null},{"message":"add a \"{}\" format string to Display the message","code":null,"level":"help","spans":[{"file_name":"tests/ui/assertions_on_constants.rs","byte_start":293,"byte_end":293,"line_start":15,"line_end":15,"column_start":20,"column_end":20,"is_primary":true,"text":[{"text":"    assert!(false, msg.to_uppercase());","highlight_start":20,"highlight_end":20}],"label":null,"suggested_replacement":"\"{}\", ","suggestion_applicability":"MaybeIncorrect","expansion":null}],"children":[],"rendered":null}],"rendered":"error: panic message is not a string literal\n  --> tests/ui/assertions_on_constants.rs:15:20\n   |\nLL |     assert!(false, msg.to_uppercase());\n   |                    ^^^^^^^^^^^^^^^^^^\n   |\n   = note: `-D non-fmt-panic` implied by `-D warnings`\n   = note: this is no longer accepted in Rust 2021\nhelp: add a \"{}\" format string to Display the message\n   |\nLL |     assert!(false, \"{}\", msg.to_uppercase());\n   |                    ^^^^^\n\n"}

------------------------------------------

normalized stderr:
normalized stderr:
error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:5:1
   |
LL | / impl From<String> for Foo {
LL | |     fn from(s: String) -> Self {
LL | |         Foo(s.parse().unwrap())
LL | |     }
LL | | }
   |
note: the lint level is defined here
  --> $DIR/fallible_impl_from.rs:1:9
   |
   |
LL | #![deny(clippy::fallible_impl_from)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
note: potential failure(s)
  --> $DIR/fallible_impl_from.rs:7:13
   |
LL |         Foo(s.parse().unwrap())


error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:26:1
   |
LL | / impl From<usize> for Invalid {
LL | |     fn from(i: usize) -> Invalid {
LL | |         if i != 42 {
LL | |             panic!();
LL | |     }
LL | | }
   | |_^
   |
   |
   = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
note: potential failure(s)
  --> $DIR/fallible_impl_from.rs:29:13
   |
LL |             panic!();
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:35:1
   |
LL | / impl From<Option<String>> for Invalid {
LL | |     fn from(s: Option<String>) -> Invalid {
LL | |         let s = s.unwrap();
LL | |         if !s.is_empty() {
LL | |     }
LL | | }
   | |_^
   |
   |
   = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
note: potential failure(s)
  --> $DIR/fallible_impl_from.rs:37:17
LL |         let s = s.unwrap();
   |                 ^^^^^^^^^^
   |                 ^^^^^^^^^^
LL |         if !s.is_empty() {
LL |             panic!(42);
   |             ^^^^^^^^^^^
LL |         } else if s.parse::<u32>().unwrap() != 42 {
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^
LL |             panic!("{:?}", s);
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:53:1
   |
LL | / impl<'a> From<&'a mut <Box<u32> as ProjStrTrait>::ProjString> for Invalid {
LL | |     fn from(s: &'a mut <Box<u32> as ProjStrTrait>::ProjString) -> Invalid {
LL | |         if s.parse::<u32>().ok().unwrap() != 42 {
LL | |             panic!("{:?}", s);
LL | |     }
LL | | }
   | |_^
   |
   |
   = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
note: potential failure(s)
  --> $DIR/fallible_impl_from.rs:55:12
   |
LL |         if s.parse::<u32>().ok().unwrap() != 42 {
   |            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
LL |             panic!("{:?}", s);
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: panic message is not a string literal
  --> $DIR/fallible_impl_from.rs:39:20
  --> $DIR/fallible_impl_from.rs:39:20
   |
LL |             panic!(42);
   |
   |
   = note: `-D non-fmt-panic` implied by `-D warnings`
   = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
   |
LL |             panic!("{}", 42);
   |                    ^^^^^
help: or use std::panic::panic_any instead
LL |             std::panic::panic_any(42);
   |             ^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 5 previous errors
error: aborting due to 5 previous errors



expected stderr:
error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:5:1
   |
LL | / impl From<String> for Foo {
LL | |     fn from(s: String) -> Self {
LL | |         Foo(s.parse().unwrap())
LL | |     }
LL | | }
   |
note: the lint level is defined here
  --> $DIR/fallible_impl_from.rs:1:9
   |
   |
LL | #![deny(clippy::fallible_impl_from)]
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^
   = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
note: potential failure(s)
  --> $DIR/fallible_impl_from.rs:7:13
   |
LL |         Foo(s.parse().unwrap())


error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:26:1
   |
LL | / impl From<usize> for Invalid {
LL | |     fn from(i: usize) -> Invalid {
LL | |         if i != 42 {
LL | |             panic!();
LL | |     }
LL | | }
   | |_^
   |
   |
   = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
note: potential failure(s)
  --> $DIR/fallible_impl_from.rs:29:13
   |
LL |             panic!();
   = note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)


error: consider implementing `TryFrom` instead
  --> $DIR/fallible_impl_from.rs:35:1
   |
LL | / impl From<Option<String>> for Invalid {
LL | |     fn from(s: Option<String>) -> Invalid {
LL | |         let s = s.unwrap();
LL | |         if !s.is_empty() {
LL | |     }
LL | | }
   | |_^
   |
   |
   = help: `From` is intended for infallible conversions only. Use `TryFrom` if there's a possibility for the conversion to fail.
note: potential failure(s)
  --> $DIR/fallible_impl_from.rs:37:17
LL |         let s = s.unwrap();
   |                 ^^^^^^^^^^
   |                 ^^^^^^^^^^
LL |         if !s.is_empty() {
LL |             panic!(42);
   |             ^^^^^^^^^^^
LL |         } else if s.parse::<u32>().unwrap() != 42 {
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 4, 2021
Rollup of 9 pull requests

Successful merges:

 - rust-lang#74304 (Stabilize the Wake trait)
 - rust-lang#79805 (Rename Iterator::fold_first to reduce and stabilize it)
 - rust-lang#81556 (introduce future-compatibility warning for forbidden lint groups)
 - rust-lang#81645 (Add lint for `panic!(123)` which is not accepted in Rust 2021.)
 - rust-lang#81710 (OsStr eq_ignore_ascii_case takes arg by value)
 - rust-lang#81711 (add #[inline] to all the public IpAddr functions)
 - rust-lang#81725 (Move test to be with the others)
 - rust-lang#81727 (Revert stabilizing integer::BITS.)
 - rust-lang#81745 (Stabilize poison API of Once, rename poisoned())

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 87b269a into rust-lang:master Feb 5, 2021
@rustbot rustbot added this to the 1.51.0 milestone Feb 5, 2021
@ehuss
Copy link
Contributor

ehuss commented Feb 6, 2021

This seems like it is going to cause a lot of churn (for example, it broke Cargo's CI). It's not clear why this needs to be a warning. Was it considered to make this allowed on 2018 and make it part of the rust-2021-compatibility group?

@m-ou-se m-ou-se deleted the panic-lint branch February 6, 2021 17:01
@m-ou-se
Copy link
Member Author

m-ou-se commented Feb 6, 2021

@ehuss See rfc 3007. The idea was that panic!(123) and panic!("{}") are not just incompatible with edition 2021, but are probably bugs.

But if this too often causes warnings for cases where it was intentional, we should probably only warn in a subset of the cases by default, and make the rest a allow-by-default migration lint.

Note that as a lint, it doesn't show up for dependencies at all. So it shouldn't break any builds unless you're bulding with deny(warnings) and trigger the lint in your local crate(s).

@taiki-e
Copy link
Member

taiki-e commented Feb 6, 2021

Another problem is the suggested alternative (std::panic::panic_any) is not yet available in the stable Rust.
AFAIK, currently, some of the cases this lint warns can't seem to be fixed in projects that support stable Rust. (e.g., tokio-rs/slab#80)

EDIT: The way mentioned in this comment works well on stable rust.

@ehuss
Copy link
Contributor

ehuss commented Feb 6, 2021

Hm, ok after reading the justifications I think it makes more sense. It just seemed a little surprising to me because the following:

assert!(stuff.contains("thing"), stuff);

doesn't seem unreasonable (display the string if it doesn't contain the text). It is not immediately obvious to me from the warning why that wouldn't be allowed, since panics have always supported arbitrary payloads.

Cargo denies warnings on CI, just like rust-lang/rust does.

I've been contemplating how to provide better explanations for lints, and I think this is a good example. I'd like to make the descriptions in the lint listing more accessible (maybe via something like the --explain or -Zteach flag, or in-editor buttons). I'm uncertain how helpful that would be (and I'm not sure if anyone is particularly interested in improving that).

bors added a commit to rust-lang/cargo that referenced this pull request Feb 6, 2021
Fix warnings of the new non_fmt_panic lint

This fixes the CI failure since the latest nightly. See rust-lang/rust#81645
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 10, 2021
Use format string in bootstrap panic instead of a string directly

This fixes the following warning when compiling with nightly:

```
warning: panic message is not a string literal
    --> src/bootstrap/builder.rs:1515:24
     |
1515 |                 panic!(out);
     |                        ^^^
     |
     = note: `#[warn(non_fmt_panic)]` on by default
     = note: this is no longer accepted in Rust 2021
help: add a "{}" format string to Display the message
     |
1515 |                 panic!("{}", out);
     |                        ^^^^^
help: or use std::panic::panic_any instead
     |
1515 |                 std::panic::panic_any(out);
     |                 ^^^^^^^^^^^^^^^^^^^^^^
```

Found while working on rust-lang#79540. cc rust-lang#81645, which landed in 1.51.
ehuss pushed a commit to ehuss/cargo that referenced this pull request Feb 22, 2021
Fix warnings of the new non_fmt_panic lint

This fixes the CI failure since the latest nightly. See rust-lang/rust#81645
tqdv added a commit to tqdv/tear that referenced this pull request Apr 11, 2021
@m-ou-se m-ou-se added this to Completed items in 2021 Edition Blockers Apr 26, 2021
alatiera pushed a commit to alatiera/gnome-podcasts that referenced this pull request Apr 27, 2021
Rust 2021 makes std::panic and core::panic identical.
This caused a bunch of warnings to pop up.
see: rust-lang/rust#81645
and: rust-lang/rust#80162

This updates the use of panic! and debug_assert to the new format.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
2021 Edition Blockers
  
Completed items
Development

Successfully merging this pull request may close these issues.

None yet

10 participants