diff options
| author | Jonas Schievink <jonasschievink@gmail.com> | 2020-11-15 13:39:56 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-15 13:39:56 +0100 |
| commit | 9c6d3c09404ba8f7504f8889b7afd82fa4bcee97 (patch) | |
| tree | 46fcb1caa2a905d4abb2c86d3405a452b47408f6 | |
| parent | aa685e2024874860c71887c4e18d916f1d989af8 (diff) | |
| parent | 7eb1a1afcfd5564f0d78f37c9c6397a070d794c2 (diff) | |
| download | rust-9c6d3c09404ba8f7504f8889b7afd82fa4bcee97.tar.gz rust-9c6d3c09404ba8f7504f8889b7afd82fa4bcee97.zip | |
Rollup merge of #79031 - camelid:mir-validate-local-decl, r=jonas-schievink
Validate that locals have a corresponding `LocalDecl` Fixes #73356.
| -rw-r--r-- | compiler/rustc_mir/src/transform/validate.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_mir/src/transform/validate.rs b/compiler/rustc_mir/src/transform/validate.rs index 876ecee80c6..75399e9c32c 100644 --- a/compiler/rustc_mir/src/transform/validate.rs +++ b/compiler/rustc_mir/src/transform/validate.rs @@ -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); |
