1
1
use clippy_utils:: diagnostics:: span_lint_and_then;
2
2
use clippy_utils:: is_from_proc_macro;
3
3
use clippy_utils:: source:: { IntoSpan , SpanRangeExt } ;
4
+ use rustc_ast:: { Local , TyKind } ;
4
5
use rustc_errors:: Applicability ;
5
- use rustc_hir:: { LetStmt , TyKind } ;
6
- use rustc_lint:: { LateContext , LateLintPass } ;
6
+ use rustc_lint:: { EarlyContext , EarlyLintPass , LintContext } ;
7
7
use rustc_session:: declare_lint_pass;
8
8
9
9
declare_clippy_lint ! {
@@ -26,14 +26,14 @@ declare_clippy_lint! {
26
26
}
27
27
declare_lint_pass ! ( UnderscoreTyped => [ LET_WITH_TYPE_UNDERSCORE ] ) ;
28
28
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 < ' tcx > ( & mut self , cx : & EarlyContext < ' tcx > , 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 '_'
33
33
&& local. span . eq_ctxt ( ty. span )
34
- && let sm = cx. tcx . sess . source_map ( )
34
+ && let sm = cx. sess ( ) . source_map ( )
35
35
&& !local. span . in_external_macro ( sm)
36
- && !is_from_proc_macro ( cx, ty)
36
+ && !is_from_proc_macro ( cx, & * * ty)
37
37
{
38
38
let span_to_remove = sm
39
39
. span_extend_to_prev_char_before ( ty. span , ':' , true )
0 commit comments