Skip to content

Commit 2d9d81f

Browse files
committed
Checking for proc_macro not only when local.init is Some
1 parent df200aa commit 2d9d81f

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

clippy_lints/src/let_underscore.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,18 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore {
192192
if local.pat.default_binding_modes && local.ty.is_none() {
193193
// When `default_binding_modes` is true, the `let` keyword is present.
194194

195-
if let Some(init) = local.init {
196-
// Ignore function calls that return impl traits...
197-
if matches!(init.kind, ExprKind::Call(_, _) | ExprKind::MethodCall(_, _, _, _)) {
198-
let expr_ty = cx.typeck_results().expr_ty(init);
199-
if expr_ty.is_impl_trait() {
200-
return;
201-
}
202-
}
203-
// Ignore if it is from a procedural macro...
204-
if is_from_proc_macro(cx, init) {
205-
return;
206-
}
195+
// Ignore function calls that return impl traits...
196+
if let Some(init) = local.init &&
197+
matches!(init.kind, ExprKind::Call(_, _) | ExprKind::MethodCall(_, _, _, _)) {
198+
let expr_ty = cx.typeck_results().expr_ty(init);
199+
if expr_ty.is_impl_trait() {
200+
return;
201+
}
202+
}
203+
204+
// Ignore if it is from a procedural macro...
205+
if is_from_proc_macro(cx, init) {
206+
return;
207207
}
208208

209209
span_lint_and_help(

0 commit comments

Comments
 (0)