diff --git a/examples/restriction/question_mark_in_expression/Cargo.toml b/examples/restriction/question_mark_in_expression/Cargo.toml index 527e6d965..03406144d 100644 --- a/examples/restriction/question_mark_in_expression/Cargo.toml +++ b/examples/restriction/question_mark_in_expression/Cargo.toml @@ -10,8 +10,8 @@ publish = false crate-type = ["cdylib"] [[example]] -name = "assign_op" -path = "ui/assign_op.rs" +name = "assign" +path = "ui/assign.rs" [[example]] name = "clone" diff --git a/examples/restriction/question_mark_in_expression/src/lib.rs b/examples/restriction/question_mark_in_expression/src/lib.rs index 36eab130f..e3ce2de15 100644 --- a/examples/restriction/question_mark_in_expression/src/lib.rs +++ b/examples/restriction/question_mark_in_expression/src/lib.rs @@ -39,19 +39,21 @@ dylint_linting::declare_late_lint! { impl<'tcx> LateLintPass<'tcx> for QuestionMarkInExpression { fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &Expr<'_>) { if !cx - .tcx - .hir() - .parent_iter(expr.hir_id) - .any(|(hir_id, _)| cx.tcx.hir().span(hir_id).in_derive_expansion()) + .tcx + .hir() + .parent_iter(expr.hir_id) + .any(|(hir_id, _)| cx.tcx.hir().span(hir_id).in_derive_expansion()) && let ExprKind::Match(_, _, MatchSource::TryDesugar(_)) = expr.kind && let Some((Node::Expr(ancestor), child_hir_id)) = get_filtered_ancestor(cx, expr.hir_id) - // smoelius: `AssignOp`, `If`, `Let`, and `Match` expressions get a pass. + // smoelius: `Assign`, `AssignOp`, `If`, `Let`, and `Match` expressions get a pass. && !match ancestor.kind { ExprKind::Let(..) => true, ExprKind::If(condition, _, _) => condition.hir_id == child_hir_id, ExprKind::Match(scrutinee, _, _) => scrutinee.hir_id == child_hir_id, - ExprKind::AssignOp(_, _, expr) => expr.hir_id == child_hir_id, + ExprKind::Assign(_, expr, _) | ExprKind::AssignOp(_, _, expr) => { + expr.hir_id == child_hir_id + } _ => false, } { diff --git a/examples/restriction/question_mark_in_expression/ui/assign_op.rs b/examples/restriction/question_mark_in_expression/ui/assign.rs similarity index 89% rename from examples/restriction/question_mark_in_expression/ui/assign_op.rs rename to examples/restriction/question_mark_in_expression/ui/assign.rs index 6c41cacdc..84e4d2a05 100644 --- a/examples/restriction/question_mark_in_expression/ui/assign_op.rs +++ b/examples/restriction/question_mark_in_expression/ui/assign.rs @@ -2,6 +2,7 @@ fn main() -> Result<(), ()> { let mut x = 0; + x = foo()?; x += foo()?; Ok(()) } diff --git a/examples/restriction/question_mark_in_expression/ui/assign_op.stderr b/examples/restriction/question_mark_in_expression/ui/assign.stderr similarity index 100% rename from examples/restriction/question_mark_in_expression/ui/assign_op.stderr rename to examples/restriction/question_mark_in_expression/ui/assign.stderr