Skip to content

Commit

Permalink
Show correct macro name in non_fmt_panics message.
Browse files Browse the repository at this point in the history
  • Loading branch information
m-ou-se committed Aug 16, 2021
1 parent 86bc236 commit ab8cbc3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/non_fmt_panic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc

cx.struct_span_lint(NON_FMT_PANICS, arg_span, |lint| {
let mut l = lint.build("panic message is not a string literal");
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
l.note(&format!("this usage of {}!() is deprecated; it will be a hard error in Rust 2021", symbol_str));
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
if !span.contains(arg_span) {
// No clue where this argument is coming from.
Expand Down
22 changes: 11 additions & 11 deletions src/test/ui/non-fmt-panic.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ warning: panic message is not a string literal
LL | assert!(false, S);
| ^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{}" format string to Display the message
|
Expand All @@ -74,7 +74,7 @@ warning: panic message is not a string literal
LL | assert!(false, 123);
| ^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{}" format string to Display the message
|
Expand All @@ -87,7 +87,7 @@ warning: panic message is not a string literal
LL | assert!(false, Some(123));
| ^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{:?}" format string to use the Debug implementation of `Option<i32>`
|
Expand Down Expand Up @@ -138,7 +138,7 @@ warning: panic message is not a string literal
LL | std::panic!(123);
| ^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of std::panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{}" format string to Display the message
|
Expand All @@ -155,7 +155,7 @@ warning: panic message is not a string literal
LL | core::panic!(&*"abc");
| ^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of core::panic!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{}" format string to Display the message
|
Expand Down Expand Up @@ -253,7 +253,7 @@ warning: panic message is not a string literal
LL | assert!(false, format!("{}", 1));
| ^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: the assert!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
Expand All @@ -268,7 +268,7 @@ warning: panic message is not a string literal
LL | debug_assert!(false, format!("{}", 1));
| ^^^^^^^^^^^^^^^^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of debug_assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
= note: the debug_assert!() macro supports formatting, so there's no need for the format!() macro here
help: remove the `format!(..)` macro call
Expand Down Expand Up @@ -328,7 +328,7 @@ warning: panic message is not a string literal
LL | assert!(false, v);
| ^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>

warning: panic message is not a string literal
Expand All @@ -354,7 +354,7 @@ warning: panic message is not a string literal
LL | assert!(false, v);
| ^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{:?}" format string to use the Debug implementation of `T`
|
Expand Down Expand Up @@ -384,7 +384,7 @@ warning: panic message is not a string literal
LL | assert!(false, v);
| ^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{}" format string to Display the message
|
Expand Down Expand Up @@ -414,7 +414,7 @@ warning: panic message is not a string literal
LL | assert!(false, v);
| ^
|
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
help: add a "{}" format string to Display the message
|
Expand Down

0 comments on commit ab8cbc3

Please sign in to comment.