From 059c439bec42b4044bc587f2ef25b387a0039858 Mon Sep 17 00:00:00 2001 From: Alessio Cosenza Date: Tue, 4 Apr 2023 22:59:08 +0200 Subject: [PATCH] Add check `from_expansion` --- clippy_lints/src/redundant_type_annotations.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clippy_lints/src/redundant_type_annotations.rs b/clippy_lints/src/redundant_type_annotations.rs index c4edb1bb6f9d..00c91fae6506 100644 --- a/clippy_lints/src/redundant_type_annotations.rs +++ b/clippy_lints/src/redundant_type_annotations.rs @@ -102,7 +102,8 @@ fn is_redundant_in_func_call<'tcx>( impl LateLintPass<'_> for RedundantTypeAnnotations { fn check_local<'tcx>(&mut self, cx: &LateContext<'tcx>, local: &'tcx rustc_hir::Local<'tcx>) { // type annotation part - if let Some(ty) = &local.ty + if !local.span.from_expansion() + && let Some(ty) = &local.ty && let hir::TyKind::Path(ty_path) = &ty.kind && let hir::QPath::Resolved(_, resolved_path_ty) = ty_path