diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2023-10-31 15:47:18 +0000 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2023-11-06 16:23:09 +0000 |
| commit | 868de8e76bbc6ae1a2b857ff2cdf5dc5cab0eadd (patch) | |
| tree | 66122d6cafe6ff8693471cdbc81462a262222953 /compiler | |
| parent | 2b599927368823496942da52b31bea81917f0ec7 (diff) | |
| download | rust-868de8e76bbc6ae1a2b857ff2cdf5dc5cab0eadd.tar.gz rust-868de8e76bbc6ae1a2b857ff2cdf5dc5cab0eadd.zip | |
Visit patterns in THIR let expressions
This fixes some THIR unsafety checking errors not being emitted for let expressions in these situations.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/thir/visit.rs | 3 | ||||
| -rw-r--r-- | compiler/rustc_mir_build/src/check_unsafety.rs | 8 |
2 files changed, 2 insertions, 9 deletions
diff --git a/compiler/rustc_middle/src/thir/visit.rs b/compiler/rustc_middle/src/thir/visit.rs index d03d92c3a4b..8feefb4c03c 100644 --- a/compiler/rustc_middle/src/thir/visit.rs +++ b/compiler/rustc_middle/src/thir/visit.rs @@ -66,8 +66,9 @@ pub fn walk_expr<'a, 'tcx: 'a, V: Visitor<'a, 'tcx>>(visitor: &mut V, expr: &Exp Use { source } => visitor.visit_expr(&visitor.thir()[source]), NeverToAny { source } => visitor.visit_expr(&visitor.thir()[source]), PointerCoercion { source, cast: _ } => visitor.visit_expr(&visitor.thir()[source]), - Let { expr, .. } => { + Let { expr, ref pat } => { visitor.visit_expr(&visitor.thir()[expr]); + visitor.visit_pat(pat); } Loop { body } => visitor.visit_expr(&visitor.thir()[body]), Match { scrutinee, ref arms, .. } => { diff --git a/compiler/rustc_mir_build/src/check_unsafety.rs b/compiler/rustc_mir_build/src/check_unsafety.rs index 373ed61ff87..3d895c131a8 100644 --- a/compiler/rustc_mir_build/src/check_unsafety.rs +++ b/compiler/rustc_mir_build/src/check_unsafety.rs @@ -495,14 +495,6 @@ impl<'a, 'tcx> Visitor<'a, 'tcx> for UnsafetyVisitor<'a, 'tcx> { } } } - ExprKind::Let { expr: expr_id, .. } => { - let let_expr = &self.thir[expr_id]; - if let ty::Adt(adt_def, _) = let_expr.ty.kind() - && adt_def.is_union() - { - self.requires_unsafe(expr.span, AccessToUnionField); - } - } _ => {} } visit::walk_expr(self, expr); |
