11use clippy_utils:: diagnostics:: span_lint_and_help;
2- use clippy_utils:: source :: snippet ;
2+ use clippy_utils:: is_from_proc_macro ;
33use rustc_hir:: { LetStmt , TyKind } ;
44use rustc_lint:: { LateContext , LateLintPass } ;
55use rustc_middle:: lint:: in_external_macro;
@@ -25,19 +25,14 @@ declare_clippy_lint! {
2525}
2626declare_lint_pass ! ( UnderscoreTyped => [ LET_WITH_TYPE_UNDERSCORE ] ) ;
2727
28- impl LateLintPass < ' _ > for UnderscoreTyped {
29- fn check_local ( & mut self , cx : & LateContext < ' _ > , local : & LetStmt < ' _ > ) {
30- if !in_external_macro ( cx. tcx . sess , local. span )
31- && let Some ( ty) = local. ty // Ensure that it has a type defined
28+ impl < ' tcx > LateLintPass < ' tcx > for UnderscoreTyped {
29+ fn check_local ( & mut self , cx : & LateContext < ' tcx > , local : & ' tcx LetStmt < ' _ > ) {
30+ if let Some ( ty) = local. ty // Ensure that it has a type defined
3231 && let TyKind :: Infer = & ty. kind // that type is '_'
3332 && local. span . eq_ctxt ( ty. span )
33+ && !in_external_macro ( cx. tcx . sess , local. span )
34+ && !is_from_proc_macro ( cx, ty)
3435 {
35- // NOTE: Using `is_from_proc_macro` on `init` will require that it's initialized,
36- // this doesn't. Alternatively, `WithSearchPat` can be implemented for `Ty`
37- if snippet ( cx, ty. span , "_" ) . trim ( ) != "_" {
38- return ;
39- }
40-
4136 span_lint_and_help (
4237 cx,
4338 LET_WITH_TYPE_UNDERSCORE ,
0 commit comments