mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 23:20:39 +00:00
manual_unwrap_or_default
: Check HIR tree first.
This commit is contained in:
parent
5d333e862b
commit
7a942a5c99
1 changed files with 4 additions and 5 deletions
|
@ -172,11 +172,10 @@ fn handle<'tcx>(cx: &LateContext<'tcx>, if_let_or_match: IfLetOrMatch<'tcx>, exp
|
||||||
|
|
||||||
impl<'tcx> LateLintPass<'tcx> for ManualUnwrapOrDefault {
|
impl<'tcx> LateLintPass<'tcx> for ManualUnwrapOrDefault {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>) {
|
||||||
if expr.span.from_expansion() || in_constant(cx, expr.hir_id) {
|
if let Some(if_let_or_match) = IfLetOrMatch::parse(cx, expr)
|
||||||
return;
|
&& !expr.span.from_expansion()
|
||||||
}
|
&& !in_constant(cx, expr.hir_id)
|
||||||
// Call handle only if the expression is `if let` or `match`
|
{
|
||||||
if let Some(if_let_or_match) = IfLetOrMatch::parse(cx, expr) {
|
|
||||||
handle(cx, if_let_or_match, expr);
|
handle(cx, if_let_or_match, expr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue