Skip to content

Commit 7a942a5

Browse files
committed
manual_unwrap_or_default: Check HIR tree first.
1 parent 5d333e8 commit 7a942a5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

clippy_lints/src/manual_unwrap_or_default.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,10 @@ fn handle<'tcx>(cx: &LateContext<'tcx>, if_let_or_match: IfLetOrMatch<'tcx>, exp
172172

173173
impl<'tcx> LateLintPass<'tcx> for ManualUnwrapOrDefault {
174174
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
175-
if expr.span.from_expansion() || in_constant(cx, expr.hir_id) {
176-
return;
177-
}
178-
// Call handle only if the expression is `if let` or `match`
179-
if let Some(if_let_or_match) = IfLetOrMatch::parse(cx, expr) {
175+
if let Some(if_let_or_match) = IfLetOrMatch::parse(cx, expr)
176+
&& !expr.span.from_expansion()
177+
&& !in_constant(cx, expr.hir_id)
178+
{
180179
handle(cx, if_let_or_match, expr);
181180
}
182181
}

0 commit comments

Comments
 (0)