Skip to content

Commit 9c6d3c0

Browse files
Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-schievink
Validate that locals have a corresponding `LocalDecl` Fixes #73356.
2 parents aa685e2 + 7eb1a1a commit 9c6d3c0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

compiler/rustc_mir/src/transform/validate.rs

+7
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
181181

182182
impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
183183
fn visit_local(&mut self, local: &Local, context: PlaceContext, location: Location) {
184+
if self.body.local_decls.get(*local).is_none() {
185+
self.fail(
186+
location,
187+
format!("local {:?} has no corresponding declaration in `body.local_decls`", local),
188+
);
189+
}
190+
184191
if self.reachable_blocks.contains(location.block) && context.is_use() {
185192
// Uses of locals must occur while the local's storage is allocated.
186193
self.storage_liveness.seek_after_primary_effect(location);

0 commit comments

Comments
 (0)