@@ -7,8 +7,8 @@ use rustc_session::declare_lint_pass;
7
7
use rustc_span:: { BytePos , Span } ;
8
8
9
9
use clippy_utils:: diagnostics:: span_lint;
10
+ use clippy_utils:: is_from_proc_macro;
10
11
use clippy_utils:: mir:: enclosing_mir;
11
- use clippy_utils:: source:: snippet_opt;
12
12
13
13
declare_clippy_lint ! {
14
14
/// ### What it does
@@ -80,8 +80,8 @@ fn emit_lint(cx: &LateContext<'_>, expr: &Expr<'_>, spans: &[(Span, Option<Strin
80
80
}
81
81
}
82
82
83
- impl LateLintPass < ' _ > for LiteralStringWithFormattingArg {
84
- fn check_expr ( & mut self , cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) {
83
+ impl < ' tcx > LateLintPass < ' tcx > for LiteralStringWithFormattingArg {
84
+ fn check_expr ( & mut self , cx : & LateContext < ' tcx > , expr : & Expr < ' tcx > ) {
85
85
if expr. span . from_expansion ( ) || expr. span . is_dummy ( ) {
86
86
return ;
87
87
}
@@ -96,15 +96,10 @@ impl LateLintPass<'_> for LiteralStringWithFormattingArg {
96
96
} ,
97
97
_ => return ,
98
98
} ;
99
- let Some ( snippet) = snippet_opt ( cx, expr. span ) else {
100
- return ;
101
- } ;
102
- let fmt_str = symbol. as_str ( ) ;
103
- // If the literal has been generated by the macro, the snippet should not contain it,
104
- // allowing us to skip it.
105
- if !snippet. contains ( fmt_str) {
99
+ if is_from_proc_macro ( cx, expr) {
106
100
return ;
107
101
}
102
+ let fmt_str = symbol. as_str ( ) ;
108
103
let lo = expr. span . lo ( ) ;
109
104
let mut current = fmt_str;
110
105
let mut diff_len = 0 ;
0 commit comments