Skip to content

Commit 2bf88ca

Browse files
committed
make the lint early-pass
1 parent c8c73a4 commit 2bf88ca

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

clippy_lints/src/let_with_type_underscore.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use clippy_utils::diagnostics::span_lint_and_then;
22
use clippy_utils::is_from_proc_macro;
33
use clippy_utils::source::{IntoSpan, SpanRangeExt};
4+
use rustc_ast::{Local, TyKind};
45
use rustc_errors::Applicability;
5-
use rustc_hir::{LetStmt, TyKind};
6-
use rustc_lint::{LateContext, LateLintPass};
6+
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
77
use rustc_session::declare_lint_pass;
88

99
declare_clippy_lint! {
@@ -26,14 +26,14 @@ declare_clippy_lint! {
2626
}
2727
declare_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<'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 '_'
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)

clippy_lints/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -742,7 +742,7 @@ pub fn register_lint_passes(store: &mut rustc_lint::LintStore, conf: &'static Co
742742
store.register_late_pass(|_| Box::new(missing_assert_message::MissingAssertMessage));
743743
store.register_late_pass(|_| Box::new(needless_maybe_sized::NeedlessMaybeSized));
744744
store.register_late_pass(|_| Box::new(redundant_async_block::RedundantAsyncBlock));
745-
store.register_late_pass(|_| Box::new(let_with_type_underscore::UnderscoreTyped));
745+
store.register_early_pass(|| Box::new(let_with_type_underscore::UnderscoreTyped));
746746
store.register_late_pass(move |_| Box::new(manual_main_separator_str::ManualMainSeparatorStr::new(conf)));
747747
store.register_late_pass(|_| Box::new(unnecessary_struct_initialization::UnnecessaryStruct));
748748
store.register_late_pass(move |_| Box::new(unnecessary_box_returns::UnnecessaryBoxReturns::new(conf)));

0 commit comments

Comments
 (0)