diff options
| author | Michael Goulet <michael@errs.io> | 2024-04-10 15:06:46 -0400 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-04-10 15:07:13 -0400 |
| commit | 889ca7e2164a0032d668cb6b1e148507dc2bd9b2 (patch) | |
| tree | c9c2378a1824f2fe3b946a0d3812c07c50fe3fae /compiler | |
| parent | 5974fe87c4d711949caa64fc1e8366685c8fc190 (diff) | |
| download | rust-889ca7e2164a0032d668cb6b1e148507dc2bd9b2.tar.gz rust-889ca7e2164a0032d668cb6b1e148507dc2bd9b2.zip | |
Don't delay a bug if we suggest adding a semicolon to the RHS of an assign operator
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_hir_typeck/src/op.rs | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/compiler/rustc_hir_typeck/src/op.rs b/compiler/rustc_hir_typeck/src/op.rs index b17b312a797..94b723f694e 100644 --- a/compiler/rustc_hir_typeck/src/op.rs +++ b/compiler/rustc_hir_typeck/src/op.rs @@ -382,11 +382,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { (err, output_def_id) } }; - if self.check_for_missing_semi(expr, &mut err) - && let hir::Node::Expr(expr) = self.tcx.parent_hir_node(expr.hir_id) - && let hir::ExprKind::Assign(..) = expr.kind + + // Try to suggest a semicolon if it's `A \n *B` where `B` is a place expr + let maybe_missing_semi = self.check_for_missing_semi(expr, &mut err); + + // We defer to the later error produced by `check_lhs_assignable`. + // We only downgrade this if it's the LHS, though. + if maybe_missing_semi + && let hir::Node::Expr(parent) = self.tcx.parent_hir_node(expr.hir_id) + && let hir::ExprKind::Assign(lhs, _, _) = parent.kind + && lhs.hir_id == expr.hir_id { - // We defer to the later error produced by `check_lhs_assignable`. err.downgrade_to_delayed_bug(); } |
