Skip to content

Commit fc81b7c

Browse files
m-ou-seehuss
authored andcommitted
Rename panic_fmt lint to non_fmt_panic.
1 parent eba5432 commit fc81b7c

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

compiler/rustc_lint/src/panic_fmt.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ use rustc_parse_format::{ParseMode, Parser, Piece};
77
use rustc_span::{sym, InnerSpan};
88

99
declare_lint! {
10-
/// The `panic_fmt` lint detects `panic!("..")` with `{` or `}` in the string literal.
10+
/// The `non_fmt_panic` lint detects `panic!("..")` with `{` or `}` in the string literal
11+
/// when it is not used as a format string.
1112
///
1213
/// ### Example
1314
///
@@ -23,13 +24,13 @@ declare_lint! {
2324
/// with a single argument does not use `format_args!()`.
2425
/// A future edition of Rust will interpret this string as format string,
2526
/// which would break this.
26-
PANIC_FMT,
27+
NON_FMT_PANIC,
2728
Warn,
2829
"detect braces in single-argument panic!() invocations",
2930
report_in_external_macro
3031
}
3132

32-
declare_lint_pass!(PanicFmt => [PANIC_FMT]);
33+
declare_lint_pass!(PanicFmt => [NON_FMT_PANIC]);
3334

3435
impl<'tcx> LateLintPass<'tcx> for PanicFmt {
3536
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
9293
[] => vec![fmt_span],
9394
v => v.iter().map(|span| fmt_span.from_inner(*span)).collect(),
9495
};
95-
cx.struct_span_lint(PANIC_FMT, arg_spans, |lint| {
96+
cx.struct_span_lint(NON_FMT_PANIC, arg_spans, |lint| {
9697
let mut l = lint.build(match n_arguments {
9798
1 => "panic message contains an unused formatting placeholder",
9899
_ => "panic message contains unused formatting placeholders",
@@ -129,7 +130,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
129130
Some(v) if v.len() == 1 => "panic message contains a brace",
130131
_ => "panic message contains braces",
131132
};
132-
cx.struct_span_lint(PANIC_FMT, brace_spans.unwrap_or(vec![expn.call_site]), |lint| {
133+
cx.struct_span_lint(NON_FMT_PANIC, brace_spans.unwrap_or(vec![expn.call_site]), |lint| {
133134
let mut l = lint.build(msg);
134135
l.note("this message is not used as a format string, but will be in a future Rust edition");
135136
if expn.call_site.contains(arg.span) {

src/test/ui/fmt/format-args-capture.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn panic_with_single_argument_does_not_get_formatted() {
3131
// RFC #2795 suggests that this may need to change so that captured arguments are formatted.
3232
// For stability reasons this will need to part of an edition change.
3333

34-
#[allow(panic_fmt)]
34+
#[allow(non_fmt_panic)]
3535
let msg = std::panic::catch_unwind(|| {
3636
panic!("{foo}");
3737
}).unwrap_err();

src/test/ui/macros/macro-comma-behavior-rpass.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn writeln_1arg() {
5757
//
5858
// (Example: Issue #48042)
5959
#[test]
60-
#[allow(panic_fmt)]
60+
#[allow(non_fmt_panic)]
6161
fn to_format_or_not_to_format() {
6262
// ("{}" is the easiest string to test because if this gets
6363
// sent to format_args!, it'll simply fail to compile.

src/test/ui/panic-brace.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ warning: panic message contains a brace
44
LL | panic!("here's a brace: {");
55
| ^
66
|
7-
= note: `#[warn(panic_fmt)]` on by default
7+
= note: `#[warn(non_fmt_panic)]` on by default
88
= note: this message is not used as a format string, but will be in a future Rust edition
99
help: add a "{}" format string to use the message literally
1010
|

0 commit comments

Comments
 (0)