diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2024-06-13 18:34:25 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2024-07-07 18:11:55 -0400 |
| commit | 7a942a5c993233700a217dae629915bba456d698 (patch) | |
| tree | 4ce180b086b0cdc0e00d5c89e4a4b4ab22c54abc | |
| parent | 5d333e862b5a2df69333952c331cdb06b4fd12e4 (diff) | |
| download | rust-7a942a5c993233700a217dae629915bba456d698.tar.gz rust-7a942a5c993233700a217dae629915bba456d698.zip | |
`manual_unwrap_or_default`: Check HIR tree first.
| -rw-r--r-- | clippy_lints/src/manual_unwrap_or_default.rs | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/clippy_lints/src/manual_unwrap_or_default.rs b/clippy_lints/src/manual_unwrap_or_default.rs index 58b2ebebbf0..f1acc4b2174 100644 --- a/clippy_lints/src/manual_unwrap_or_default.rs +++ b/clippy_lints/src/manual_unwrap_or_default.rs @@ -172,11 +172,10 @@ fn handle<'tcx>(cx: &LateContext<'tcx>, if_let_or_match: IfLetOrMatch<'tcx>, exp impl<'tcx> LateLintPass<'tcx> for ManualUnwrapOrDefault { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) { - if expr.span.from_expansion() || in_constant(cx, expr.hir_id) { - return; - } - // Call handle only if the expression is `if let` or `match` - if let Some(if_let_or_match) = IfLetOrMatch::parse(cx, expr) { + if let Some(if_let_or_match) = IfLetOrMatch::parse(cx, expr) + && !expr.span.from_expansion() + && !in_constant(cx, expr.hir_id) + { handle(cx, if_let_or_match, expr); } } |
