Skip to content

Commit 75108b6

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

File tree

5 files changed

+7
-11
lines changed

5 files changed

+7
-11
lines changed

Diff for: compiler/rustc_borrowck/src/lib.rs

+2-6
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,16 +211,12 @@ 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,
218218
);
219219

220-
// `flow_inits` is large, so we drop it as soon as possible. This reduces
221-
// peak memory usage significantly on some benchmarks.
222-
drop(flow_inits);
223-
224220
// Dump MIR results into a file, if that is enabled. This let us
225221
// write unit-tests, as well as helping with debugging.
226222
nll::dump_nll_mir(&infcx, body, &regioncx, &opt_closure_req, &borrow_set);

Diff for: 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>,

Diff for: 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");

Diff for: 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.

Diff for: 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)