11use clippy_utils:: diagnostics:: span_lint_and_then;
22use clippy_utils:: is_from_proc_macro;
33use clippy_utils:: source:: { IntoSpan , SpanRangeExt } ;
4+ use rustc_ast:: { Local , TyKind } ;
45use rustc_errors:: Applicability ;
5- use rustc_hir:: { LetStmt , TyKind } ;
6- use rustc_lint:: { LateContext , LateLintPass } ;
6+ use rustc_lint:: { EarlyContext , EarlyLintPass , LintContext } ;
77use rustc_session:: declare_lint_pass;
88
99declare_clippy_lint ! {
@@ -26,14 +26,14 @@ declare_clippy_lint! {
2626}
2727declare_lint_pass ! ( UnderscoreTyped => [ LET_WITH_TYPE_UNDERSCORE ] ) ;
2828
29- impl < ' tcx > LateLintPass < ' tcx > for UnderscoreTyped {
30- fn check_local ( & mut self , cx : & LateContext < ' tcx > , local : & ' tcx LetStmt < ' _ > ) {
31- if let Some ( ty) = local. ty // Ensure that it has a type defined
32- && let TyKind :: Infer ( ( ) ) = & ty. kind // that type is '_'
29+ impl EarlyLintPass for UnderscoreTyped {
30+ fn check_local ( & mut self , cx : & EarlyContext < ' _ > , local : & Local ) {
31+ if let Some ( ty) = & local. ty // Ensure that it has a type defined
32+ && let TyKind :: Infer = ty. kind // that type is '_'
3333 && local. span . eq_ctxt ( ty. span )
34- && let sm = cx. tcx . sess . source_map ( )
34+ && let sm = cx. sess ( ) . source_map ( )
3535 && !local. span . in_external_macro ( sm)
36- && !is_from_proc_macro ( cx, ty)
36+ && !is_from_proc_macro ( cx, & * * ty)
3737 {
3838 let span_to_remove = sm
3939 . span_extend_to_prev_char_before ( ty. span , ':' , true )
0 commit comments