@@ -7,7 +7,8 @@ use rustc_parse_format::{ParseMode, Parser, Piece};
7
7
use rustc_span:: { sym, InnerSpan } ;
8
8
9
9
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.
11
12
///
12
13
/// ### Example
13
14
///
@@ -23,13 +24,13 @@ declare_lint! {
23
24
/// with a single argument does not use `format_args!()`.
24
25
/// A future edition of Rust will interpret this string as format string,
25
26
/// which would break this.
26
- PANIC_FMT ,
27
+ NON_FMT_PANIC ,
27
28
Warn ,
28
29
"detect braces in single-argument panic!() invocations" ,
29
30
report_in_external_macro
30
31
}
31
32
32
- declare_lint_pass ! ( PanicFmt => [ PANIC_FMT ] ) ;
33
+ declare_lint_pass ! ( PanicFmt => [ NON_FMT_PANIC ] ) ;
33
34
34
35
impl < ' tcx > LateLintPass < ' tcx > for PanicFmt {
35
36
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
92
93
[ ] => vec ! [ fmt_span] ,
93
94
v => v. iter ( ) . map ( |span| fmt_span. from_inner ( * span) ) . collect ( ) ,
94
95
} ;
95
- cx. struct_span_lint ( PANIC_FMT , arg_spans, |lint| {
96
+ cx. struct_span_lint ( NON_FMT_PANIC , arg_spans, |lint| {
96
97
let mut l = lint. build ( match n_arguments {
97
98
1 => "panic message contains an unused formatting placeholder" ,
98
99
_ => "panic message contains unused formatting placeholders" ,
@@ -129,7 +130,7 @@ fn check_panic<'tcx>(cx: &LateContext<'tcx>, f: &'tcx hir::Expr<'tcx>, arg: &'tc
129
130
Some ( v) if v. len ( ) == 1 => "panic message contains a brace" ,
130
131
_ => "panic message contains braces" ,
131
132
} ;
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| {
133
134
let mut l = lint. build ( msg) ;
134
135
l. note ( "this message is not used as a format string, but will be in a future Rust edition" ) ;
135
136
if expn. call_site . contains ( arg. span ) {
0 commit comments