diff options
| author | Renato Lochetti <renato.lochetti@gmail.com> | 2023-05-16 09:34:20 +0100 |
|---|---|---|
| committer | Renato Lochetti <renato.lochetti@gmail.com> | 2023-05-16 09:36:22 +0100 |
| commit | 2d9d81fc1e881f4ccf84c0509ffc23c8086cdcc6 (patch) | |
| tree | 2a36bdb31c712dca262f6be5386839216ed9d4fc | |
| parent | df200aaf39184258ad2fb5d2d9a4682fb069bbd5 (diff) | |
| download | rust-2d9d81fc1e881f4ccf84c0509ffc23c8086cdcc6.tar.gz rust-2d9d81fc1e881f4ccf84c0509ffc23c8086cdcc6.zip | |
Checking for proc_macro not only when local.init is Some
| -rw-r--r-- | clippy_lints/src/let_underscore.rs | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/clippy_lints/src/let_underscore.rs b/clippy_lints/src/let_underscore.rs index 0596ea732f3..34a9d217606 100644 --- a/clippy_lints/src/let_underscore.rs +++ b/clippy_lints/src/let_underscore.rs @@ -192,18 +192,18 @@ impl<'tcx> LateLintPass<'tcx> for LetUnderscore { if local.pat.default_binding_modes && local.ty.is_none() { // When `default_binding_modes` is true, the `let` keyword is present. - if let Some(init) = local.init { - // Ignore function calls that return impl traits... - if matches!(init.kind, ExprKind::Call(_, _) | ExprKind::MethodCall(_, _, _, _)) { - let expr_ty = cx.typeck_results().expr_ty(init); - if expr_ty.is_impl_trait() { - return; - } - } - // Ignore if it is from a procedural macro... - if is_from_proc_macro(cx, init) { - return; - } + // Ignore function calls that return impl traits... + if let Some(init) = local.init && + matches!(init.kind, ExprKind::Call(_, _) | ExprKind::MethodCall(_, _, _, _)) { + let expr_ty = cx.typeck_results().expr_ty(init); + if expr_ty.is_impl_trait() { + return; + } + } + + // Ignore if it is from a procedural macro... + if is_from_proc_macro(cx, init) { + return; } span_lint_and_help( |
