From bfa0668242ecae6fd669dee9032f6c1b026c119e Mon Sep 17 00:00:00 2001 From: Mara Bos Date: Tue, 2 Feb 2021 19:22:44 +0100 Subject: [PATCH] Rename `panic_fmt` lint to `non_fmt_panic`. --- compiler/rustc_lint/src/panic_fmt.rs | 11 ++++++----- src/test/ui/fmt/format-args-capture.rs | 2 +- src/test/ui/macros/macro-comma-behavior-rpass.rs | 2 +- src/test/ui/panic-brace.stderr | 2 +- 4 files changed, 9 insertions(+), 8 deletions(-) diff --git a/compiler/rustc_lint/src/panic_fmt.rs b/compiler/rustc_lint/src/panic_fmt.rs index 0d2b20989b0c3..e01ff1641b296 100644 --- a/compiler/rustc_lint/src/panic_fmt.rs +++ b/compiler/rustc_lint/src/panic_fmt.rs @@ -7,7 +7,8 @@ use rustc_parse_format::{ParseMode, Parser, Piece}; use rustc_span::{sym, InnerSpan}; declare_lint! { - /// The `panic_fmt` lint detects `panic!("..")` with `{` or `}` in the string literal. + /// The `non_fmt_panic` lint detects `panic!("..")` with `{` or `}` in the string literal + /// when it is not used as a format string. /// /// ### Example /// @@ -23,13 +24,13 @@ declare_lint! { /// with a single argument does not use `format_args!()`. /// A future edition of Rust will interpret this string as format string, /// which would break this. - PANIC_FMT, + NON_FMT_PANIC, Warn, "detect braces in single-argument panic!() invocations", report_in_external_macro } -declare_lint_pass!(PanicFmt => [PANIC_FMT]); +declare_lint_pass!(PanicFmt => [NON_FMT_PANIC]); impl<'tcx> LateLintPass<'tcx> for PanicFmt { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'tcx>) { @@ -92,7 +93,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc [] => vec![fmt_span], v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(), }; - cx.struct_span_lint(PANIC_FMT, arg_spans, |lint| { + cx.struct_span_lint(NON_FMT_PANIC, arg_spans, |lint| { let mut l = lint.build(match n_arguments { 1 => "panic message contains an unused formatting placeholder", _ => "panic message contains unused formatting placeholders", @@ -129,7 +130,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc Some(v) if v.len() == 1 => "panic message contains a brace", _ => "panic message contains braces", }; - cx.struct_span_lint(PANIC_FMT, brace_spans.unwrap_or(vec![expn.call_site]), |lint| { + cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or(vec![expn.call_site]), |lint| { let mut l = lint.build(msg); l.note("this message is not used as a format string, but will be in a future Rust edition"); if expn.call_site.contains(arg.span) { diff --git a/src/test/ui/fmt/format-args-capture.rs b/src/test/ui/fmt/format-args-capture.rs index 4e3fa9a3c589a..d5886a13558c6 100644 --- a/src/test/ui/fmt/format-args-capture.rs +++ b/src/test/ui/fmt/format-args-capture.rs @@ -31,7 +31,7 @@ fn panic_with_single_argument_does_not_get_formatted() { // RFC #2795 suggests that this may need to change so that captured arguments are formatted. // For stability reasons this will need to part of an edition change. - #[allow(panic_fmt)] + #[allow(non_fmt_panic)] let msg = std::panic::catch_unwind(|| { panic!("{foo}"); }).unwrap_err(); diff --git a/src/test/ui/macros/macro-comma-behavior-rpass.rs b/src/test/ui/macros/macro-comma-behavior-rpass.rs index e5e656de6fa7f..e814e075647b1 100644 --- a/src/test/ui/macros/macro-comma-behavior-rpass.rs +++ b/src/test/ui/macros/macro-comma-behavior-rpass.rs @@ -57,7 +57,7 @@ fn writeln_1arg() { // // (Example: Issue #48042) #[test] -#[allow(panic_fmt)] +#[allow(non_fmt_panic)] fn to_format_or_not_to_format() { // ("{}" is the easiest string to test because if this gets // sent to format_args!, it'll simply fail to compile. diff --git a/src/test/ui/panic-brace.stderr b/src/test/ui/panic-brace.stderr index 93808891c3c37..c2aa19c580662 100644 --- a/src/test/ui/panic-brace.stderr +++ b/src/test/ui/panic-brace.stderr @@ -4,7 +4,7 @@ warning: panic message contains a brace LL | panic!("here's a brace: {"); | ^ | - = note: `#[warn(panic_fmt)]` on by default + = note: `#[warn(non_fmt_panic)]` on by default = note: this message is not used as a format string, but will be in a future Rust edition help: add a "{}" format string to use the message literally |