Skip to content

Commit e98d376

Browse files
committed
do not re-create the LocationTable for every path
🤦
1 parent 82169b6 commit e98d376

File tree

1 file changed

+7
-2
lines changed
  • src/librustc_mir/borrow_check

1 file changed

+7
-2
lines changed

src/librustc_mir/borrow_check/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,7 @@ fn do_mir_borrowck<'a, 'gcx, 'tcx>(
245245
mir_def_id: def_id,
246246
move_data: &mdpe.move_data,
247247
param_env: param_env,
248+
location_table,
248249
movable_generator,
249250
locals_are_invalidated_at_exit: match tcx.hir.body_owner_kind(id) {
250251
hir::BodyOwnerKind::Const | hir::BodyOwnerKind::Static(_) => false,
@@ -332,6 +333,11 @@ pub struct MirBorrowckCtxt<'cx, 'gcx: 'tcx, 'tcx: 'cx> {
332333
mir: &'cx Mir<'tcx>,
333334
mir_def_id: DefId,
334335
move_data: &'cx MoveData<'tcx>,
336+
337+
/// Map from MIR `Location` to `LocationIndex`; created
338+
/// when MIR borrowck begins.
339+
location_table: &'cx LocationTable,
340+
335341
param_env: ParamEnv<'gcx>,
336342
movable_generator: bool,
337343
/// This keeps track of whether local variables are free-ed when the function
@@ -946,8 +952,7 @@ impl<'cx, 'gcx, 'tcx> MirBorrowckCtxt<'cx, 'gcx, 'tcx> {
946952
let mut error_reported = false;
947953
let tcx = self.tcx;
948954
let mir = self.mir;
949-
let location_table = &LocationTable::new(mir);
950-
let location = location_table.start_index(context.loc);
955+
let location = self.location_table.start_index(context.loc);
951956
let borrow_set = self.borrow_set.clone();
952957
each_borrow_involving_path(
953958
self,

0 commit comments

Comments
 (0)