Skip to content

Commit ab8cbc3

Browse files
committed
Show correct macro name in non_fmt_panics message.
1 parent 86bc236 commit ab8cbc3

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

compiler/rustc_lint/src/non_fmt_panic.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
102102

103103
cx.struct_span_lint(NON_FMT_PANICS, arg_span, |lint| {
104104
let mut l = lint.build("panic message is not a string literal");
105-
l.note("this usage of panic!() is deprecated; it will be a hard error in Rust 2021");
105+
l.note(&format!("this usage of {}!() is deprecated; it will be a hard error in Rust 2021", symbol_str));
106106
l.note("for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>");
107107
if !span.contains(arg_span) {
108108
// No clue where this argument is coming from.

src/test/ui/non-fmt-panic.stderr

+11-11
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ warning: panic message is not a string literal
6161
LL | assert!(false, S);
6262
| ^
6363
|
64-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
64+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
6565
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
6666
help: add a "{}" format string to Display the message
6767
|
@@ -74,7 +74,7 @@ warning: panic message is not a string literal
7474
LL | assert!(false, 123);
7575
| ^^^
7676
|
77-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
77+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
7878
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
7979
help: add a "{}" format string to Display the message
8080
|
@@ -87,7 +87,7 @@ warning: panic message is not a string literal
8787
LL | assert!(false, Some(123));
8888
| ^^^^^^^^^
8989
|
90-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
90+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
9191
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
9292
help: add a "{:?}" format string to use the Debug implementation of `Option<i32>`
9393
|
@@ -138,7 +138,7 @@ warning: panic message is not a string literal
138138
LL | std::panic!(123);
139139
| ^^^
140140
|
141-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
141+
= note: this usage of std::panic!() is deprecated; it will be a hard error in Rust 2021
142142
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
143143
help: add a "{}" format string to Display the message
144144
|
@@ -155,7 +155,7 @@ warning: panic message is not a string literal
155155
LL | core::panic!(&*"abc");
156156
| ^^^^^^^
157157
|
158-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
158+
= note: this usage of core::panic!() is deprecated; it will be a hard error in Rust 2021
159159
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
160160
help: add a "{}" format string to Display the message
161161
|
@@ -253,7 +253,7 @@ warning: panic message is not a string literal
253253
LL | assert!(false, format!("{}", 1));
254254
| ^^^^^^^^^^^^^^^^
255255
|
256-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
256+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
257257
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
258258
= note: the assert!() macro supports formatting, so there's no need for the format!() macro here
259259
help: remove the `format!(..)` macro call
@@ -268,7 +268,7 @@ warning: panic message is not a string literal
268268
LL | debug_assert!(false, format!("{}", 1));
269269
| ^^^^^^^^^^^^^^^^
270270
|
271-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
271+
= note: this usage of debug_assert!() is deprecated; it will be a hard error in Rust 2021
272272
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
273273
= note: the debug_assert!() macro supports formatting, so there's no need for the format!() macro here
274274
help: remove the `format!(..)` macro call
@@ -328,7 +328,7 @@ warning: panic message is not a string literal
328328
LL | assert!(false, v);
329329
| ^
330330
|
331-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
331+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
332332
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
333333

334334
warning: panic message is not a string literal
@@ -354,7 +354,7 @@ warning: panic message is not a string literal
354354
LL | assert!(false, v);
355355
| ^
356356
|
357-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
357+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
358358
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
359359
help: add a "{:?}" format string to use the Debug implementation of `T`
360360
|
@@ -384,7 +384,7 @@ warning: panic message is not a string literal
384384
LL | assert!(false, v);
385385
| ^
386386
|
387-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
387+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
388388
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
389389
help: add a "{}" format string to Display the message
390390
|
@@ -414,7 +414,7 @@ warning: panic message is not a string literal
414414
LL | assert!(false, v);
415415
| ^
416416
|
417-
= note: this usage of panic!() is deprecated; it will be a hard error in Rust 2021
417+
= note: this usage of assert!() is deprecated; it will be a hard error in Rust 2021
418418
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/panic-macro-consistency.html>
419419
help: add a "{}" format string to Display the message
420420
|

0 commit comments

Comments
 (0)