about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2021-10-22 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2021-10-23 09:26:22 +0200
commite4aeeca667b6ce0446703f22f95552a64954df0d (patch)
tree070dbc95a8176dd08ca603311e88dcdbfa08e003 /compiler/rustc_const_eval/src
parenta3f7c4db0373aa077f86cdd1bf11122845d3b65a (diff)
downloadrust-e4aeeca667b6ce0446703f22f95552a64954df0d.tar.gz
rust-e4aeeca667b6ce0446703f22f95552a64954df0d.zip
Reset qualifs when a storage of a local ends
to ensure that the local qualifs are affected by the state from previous
loop iterations only if the local is kept alive.

The change should be forward compatible with a stricter handling of
indirect assignments, since storage dead invalidates all existing
pointers to the local.
Diffstat (limited to 'compiler/rustc_const_eval/src')
-rw-r--r--compiler/rustc_const_eval/src/transform/check_consts/resolver.rs11
1 files changed, 10 insertions, 1 deletions
diff --git a/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs b/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs
index 8e1b69a1d74..e20b86dd452 100644
--- a/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs
+++ b/compiler/rustc_const_eval/src/transform/check_consts/resolver.rs
@@ -4,7 +4,7 @@
 
 use rustc_index::bit_set::BitSet;
 use rustc_middle::mir::visit::Visitor;
-use rustc_middle::mir::{self, BasicBlock, Local, Location};
+use rustc_middle::mir::{self, BasicBlock, Local, Location, Statement, StatementKind};
 
 use std::marker::PhantomData;
 
@@ -120,6 +120,15 @@ where
         self.super_assign(place, rvalue, location);
     }
 
+    fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) {
+        match statement.kind {
+            StatementKind::StorageDead(local) => {
+                self.qualifs_per_local.remove(local);
+            }
+            _ => self.super_statement(statement, location),
+        }
+    }
+
     fn visit_terminator(&mut self, terminator: &mir::Terminator<'tcx>, location: Location) {
         // The effect of assignment to the return place in `TerminatorKind::Call` is not applied
         // here; that occurs in `apply_call_return_effect`.