Skip to content

Commit

Permalink
Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-sch…
Browse files Browse the repository at this point in the history
…ievink

Validate that locals have a corresponding `LocalDecl`

Fixes #73356.
  • Loading branch information
jonas-schievink authored Nov 15, 2020
2 parents aa685e2 + 7eb1a1a commit 9c6d3c0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_mir/src/transform/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {

impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> {
fn visit_local(&mut self, local: &Local, context: PlaceContext, location: Location) {
if self.body.local_decls.get(*local).is_none() {
self.fail(
location,
format!("local {:?} has no corresponding declaration in `body.local_decls`", local),
);
}

if self.reachable_blocks.contains(location.block) && context.is_use() {
// Uses of locals must occur while the local's storage is allocated.
self.storage_liveness.seek_after_primary_effect(location);
Expand Down

0 comments on commit 9c6d3c0

Please sign in to comment.