Polonius: don't emit `var_maybe_initialized_on_exit`

This commit is contained in:
Albin Stjerna 2019-08-16 15:39:17 +02:00
parent 9f39e001df
commit 6568b086a2
1 changed files with 0 additions and 63 deletions

View File

@ -131,12 +131,6 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
for local in live_locals {
self.reset_local_state();
self.add_defs_for(local);
// FIXME: this is temporary until we can generate our own initialization
if self.cx.typeck.borrowck_context.all_facts.is_some() {
self.add_polonius_var_maybe_initialized_on_exit_for(local)
}
self.compute_use_live_points_for(local);
self.compute_drop_live_points_for(local);
@ -157,63 +151,6 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
}
}
// WARNING: panics if self.cx.typeck.borrowck_context.all_facts != None
//
// FIXME: this analysis (the initialization tracking) should be
// done in Polonius, but isn't yet.
fn add_polonius_var_maybe_initialized_on_exit_for(&mut self, local: Local) {
let move_path = self.cx.move_data.rev_lookup.find_local(local);
let facts = self.cx.typeck.borrowck_context.all_facts.as_mut().unwrap();
for block in self.cx.body.basic_blocks().indices() {
debug!("polonius: generating initialization facts for {:?} in {:?}", local, block);
// iterate through the block, applying the effects of each statement
// up to and including location, and populate `var_maybe_initialized_on_exit`
self.cx.flow_inits.reset_to_entry_of(block);
let start_location = Location { block, statement_index: 0 };
self.cx.flow_inits.apply_local_effect(start_location);
for statement_index in 0..self.cx.body[block].statements.len() {
let current_location = Location { block, statement_index };
self.cx.flow_inits.reconstruct_statement_effect(current_location);
// statement has not yet taken effect:
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
facts
.var_maybe_initialized_on_exit
.push((local, self.cx.location_table.start_index(current_location)));
}
// statement has now taken effect
self.cx.flow_inits.apply_local_effect(current_location);
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
facts
.var_maybe_initialized_on_exit
.push((local, self.cx.location_table.mid_index(current_location)));
}
}
let terminator_location = self.cx.body.terminator_loc(block);
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
facts
.var_maybe_initialized_on_exit
.push((local, self.cx.location_table.start_index(terminator_location)));
}
// apply the effects of the terminator and push it if needed
self.cx.flow_inits.reset_to_exit_of(block);
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
facts
.var_maybe_initialized_on_exit
.push((local, self.cx.location_table.mid_index(terminator_location)));
}
}
}
/// Clear the value of fields that are "per local variable".
fn reset_local_state(&mut self) {
self.defs.clear();