Skip to content

Commit 976ba9e

Browse files
committed
Pass flow_inits by value.
It's simpler that way, and we don't need the explicit `drop`.
1 parent f724725 commit 976ba9e

File tree

5 files changed

+7
-12
lines changed

5 files changed

+7
-12
lines changed

compiler/rustc_borrowck/src/lib.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ fn do_mir_borrowck<'tcx>(
190190
.iter_enumerated()
191191
.map(|(idx, body)| (idx, MoveData::gather_moves(body, tcx, |_| true)));
192192

193-
let mut flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
193+
let flow_inits = MaybeInitializedPlaces::new(tcx, body, &move_data)
194194
.iterate_to_fixpoint(tcx, body, Some("borrowck"))
195195
.into_results_cursor(body);
196196

@@ -211,7 +211,7 @@ fn do_mir_borrowck<'tcx>(
211211
body,
212212
&promoted,
213213
&location_table,
214-
&mut flow_inits,
214+
flow_inits,
215215
&move_data,
216216
&borrow_set,
217217
consumer_options,
@@ -225,11 +225,6 @@ fn do_mir_borrowck<'tcx>(
225225
// information.
226226
nll::dump_annotation(&infcx, body, &regioncx, &opt_closure_req, &opaque_type_values, diags);
227227

228-
// The various `flow_*` structures can be large. We drop `flow_inits` here
229-
// so it doesn't overlap with the others below. This reduces peak memory
230-
// usage significantly on some benchmarks.
231-
drop(flow_inits);
232-
233228
let flow_borrows = Borrows::new(tcx, body, &regioncx, &borrow_set).iterate_to_fixpoint(
234229
tcx,
235230
body,

compiler/rustc_borrowck/src/nll.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ pub(crate) fn compute_regions<'a, 'tcx>(
8080
body: &Body<'tcx>,
8181
promoted: &IndexSlice<Promoted, Body<'tcx>>,
8282
location_table: &LocationTable,
83-
flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
83+
flow_inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
8484
move_data: &MoveData<'tcx>,
8585
borrow_set: &BorrowSet<'tcx>,
8686
consumer_options: Option<ConsumerOptions>,

compiler/rustc_borrowck/src/type_check/liveness/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ pub(super) fn generate<'a, 'tcx>(
3232
typeck: &mut TypeChecker<'_, 'tcx>,
3333
body: &Body<'tcx>,
3434
elements: &DenseLocationMap,
35-
flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
35+
flow_inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
3636
move_data: &MoveData<'tcx>,
3737
) {
3838
debug!("liveness::generate");

compiler/rustc_borrowck/src/type_check/liveness/trace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ pub(super) fn trace<'a, 'tcx>(
3838
typeck: &mut TypeChecker<'_, 'tcx>,
3939
body: &Body<'tcx>,
4040
elements: &DenseLocationMap,
41-
flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
41+
flow_inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
4242
move_data: &MoveData<'tcx>,
4343
relevant_live_locals: Vec<Local>,
4444
boring_locals: Vec<Local>,
@@ -113,7 +113,7 @@ struct LivenessContext<'a, 'typeck, 'b, 'tcx> {
113113

114114
/// Results of dataflow tracking which variables (and paths) have been
115115
/// initialized.
116-
flow_inits: &'a mut ResultsCursor<'b, 'tcx, MaybeInitializedPlaces<'b, 'tcx>>,
116+
flow_inits: ResultsCursor<'b, 'tcx, MaybeInitializedPlaces<'b, 'tcx>>,
117117

118118
/// Index indicating where each variable is assigned, used, or
119119
/// dropped.

compiler/rustc_borrowck/src/type_check/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ pub(crate) fn type_check<'a, 'tcx>(
124124
location_table: &LocationTable,
125125
borrow_set: &BorrowSet<'tcx>,
126126
all_facts: &mut Option<AllFacts>,
127-
flow_inits: &mut ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
127+
flow_inits: ResultsCursor<'a, 'tcx, MaybeInitializedPlaces<'a, 'tcx>>,
128128
move_data: &MoveData<'tcx>,
129129
elements: Rc<DenseLocationMap>,
130130
) -> MirTypeckResults<'tcx> {

0 commit comments

Comments
 (0)