Skip to content

Commit 6568b08

Browse files
author
Albin Stjerna
committed
Polonius: don't emit var_maybe_initialized_on_exit
1 parent 9f39e00 commit 6568b08

File tree

1 file changed

+0
-63
lines changed
  • src/librustc_mir/borrow_check/nll/type_check/liveness

1 file changed

+0
-63
lines changed

src/librustc_mir/borrow_check/nll/type_check/liveness/trace.rs

-63
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
131131
for local in live_locals {
132132
self.reset_local_state();
133133
self.add_defs_for(local);
134-
135-
// FIXME: this is temporary until we can generate our own initialization
136-
if self.cx.typeck.borrowck_context.all_facts.is_some() {
137-
self.add_polonius_var_maybe_initialized_on_exit_for(local)
138-
}
139-
140134
self.compute_use_live_points_for(local);
141135
self.compute_drop_live_points_for(local);
142136

@@ -157,63 +151,6 @@ impl LivenessResults<'me, 'typeck, 'flow, 'tcx> {
157151
}
158152
}
159153

160-
// WARNING: panics if self.cx.typeck.borrowck_context.all_facts != None
161-
//
162-
// FIXME: this analysis (the initialization tracking) should be
163-
// done in Polonius, but isn't yet.
164-
fn add_polonius_var_maybe_initialized_on_exit_for(&mut self, local: Local) {
165-
let move_path = self.cx.move_data.rev_lookup.find_local(local);
166-
let facts = self.cx.typeck.borrowck_context.all_facts.as_mut().unwrap();
167-
for block in self.cx.body.basic_blocks().indices() {
168-
debug!("polonius: generating initialization facts for {:?} in {:?}", local, block);
169-
170-
// iterate through the block, applying the effects of each statement
171-
// up to and including location, and populate `var_maybe_initialized_on_exit`
172-
self.cx.flow_inits.reset_to_entry_of(block);
173-
let start_location = Location { block, statement_index: 0 };
174-
self.cx.flow_inits.apply_local_effect(start_location);
175-
176-
for statement_index in 0..self.cx.body[block].statements.len() {
177-
let current_location = Location { block, statement_index };
178-
179-
self.cx.flow_inits.reconstruct_statement_effect(current_location);
180-
181-
// statement has not yet taken effect:
182-
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
183-
facts
184-
.var_maybe_initialized_on_exit
185-
.push((local, self.cx.location_table.start_index(current_location)));
186-
}
187-
188-
// statement has now taken effect
189-
self.cx.flow_inits.apply_local_effect(current_location);
190-
191-
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
192-
facts
193-
.var_maybe_initialized_on_exit
194-
.push((local, self.cx.location_table.mid_index(current_location)));
195-
}
196-
}
197-
198-
let terminator_location = self.cx.body.terminator_loc(block);
199-
200-
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
201-
facts
202-
.var_maybe_initialized_on_exit
203-
.push((local, self.cx.location_table.start_index(terminator_location)));
204-
}
205-
206-
// apply the effects of the terminator and push it if needed
207-
self.cx.flow_inits.reset_to_exit_of(block);
208-
209-
if self.cx.flow_inits.has_any_child_of(move_path).is_some() {
210-
facts
211-
.var_maybe_initialized_on_exit
212-
.push((local, self.cx.location_table.mid_index(terminator_location)));
213-
}
214-
}
215-
}
216-
217154
/// Clear the value of fields that are "per local variable".
218155
fn reset_local_state(&mut self) {
219156
self.defs.clear();

0 commit comments

Comments
 (0)