@@ -7,7 +7,8 @@ use rustc_parse_format::{ParseMode, Parser, Piece};
77use rustc_span:: { sym, InnerSpan } ;
88
99declare_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
3435impl < ' 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 ) {
0 commit comments