Skip to content

Commit eada410

Browse files
committed
Accept LocalDefId as key for mir_validated query
1 parent 6e930f7 commit eada410

File tree

3 files changed

+15
-10
lines changed

3 files changed

+15
-10
lines changed

src/librustc_middle/query/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,12 +182,13 @@ rustc_queries! {
182182
no_hash
183183
}
184184

185-
query mir_validated(_: DefId) ->
185+
query mir_validated(key: LocalDefId) ->
186186
(
187187
&'tcx Steal<mir::Body<'tcx>>,
188188
&'tcx Steal<IndexVec<mir::Promoted, mir::Body<'tcx>>>
189189
) {
190190
no_hash
191+
desc { |tcx| "processing `{}`", tcx.def_path_str(key.to_def_id()) }
191192
}
192193

193194
/// MIR after our optimization passes have run. This is MIR that is ready

src/librustc_mir/borrow_check/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn provide(providers: &mut Providers<'_>) {
9393
}
9494

9595
fn mir_borrowck(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &BorrowCheckResult<'_> {
96-
let (input_body, promoted) = tcx.mir_validated(def_id.to_def_id());
96+
let (input_body, promoted) = tcx.mir_validated(def_id);
9797
debug!("run query mir_borrowck: {}", tcx.def_path_str(def_id.to_def_id()));
9898

9999
let opt_closure_req = tcx.infer_ctxt().enter(|infcx| {

src/librustc_mir/transform/mod.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,13 @@ fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
240240

241241
fn mir_validated(
242242
tcx: TyCtxt<'tcx>,
243-
def_id: DefId,
243+
def_id: LocalDefId,
244244
) -> (&'tcx Steal<Body<'tcx>>, &'tcx Steal<IndexVec<Promoted, Body<'tcx>>>) {
245245
// Ensure that we compute the `mir_const_qualif` for constants at
246246
// this point, before we steal the mir-const result.
247-
let _ = tcx.mir_const_qualif(def_id);
247+
let _ = tcx.mir_const_qualif(def_id.to_def_id());
248248

249-
let mut body = tcx.mir_const(def_id).steal();
249+
let mut body = tcx.mir_const(def_id.to_def_id()).steal();
250250

251251
let mut required_consts = Vec::new();
252252
let mut required_consts_visitor = RequiredConstsVisitor::new(&mut required_consts);
@@ -259,7 +259,7 @@ fn mir_validated(
259259
run_passes(
260260
tcx,
261261
&mut body,
262-
InstanceDef::Item(def_id),
262+
InstanceDef::Item(def_id.to_def_id()),
263263
None,
264264
MirPhase::Validated,
265265
&[&[
@@ -276,7 +276,7 @@ fn mir_validated(
276276
fn run_optimization_passes<'tcx>(
277277
tcx: TyCtxt<'tcx>,
278278
body: &mut Body<'tcx>,
279-
def_id: DefId,
279+
def_id: LocalDefId,
280280
promoted: Option<Promoted>,
281281
) {
282282
let post_borrowck_cleanup: &[&dyn MirPass<'tcx>] = &[
@@ -349,7 +349,7 @@ fn run_optimization_passes<'tcx>(
349349
run_passes(
350350
tcx,
351351
body,
352-
InstanceDef::Item(def_id),
352+
InstanceDef::Item(def_id.to_def_id()),
353353
promoted,
354354
MirPhase::Optimized,
355355
&[
@@ -369,9 +369,11 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
369369
return shim::build_adt_ctor(tcx, def_id);
370370
}
371371

372+
let def_id = def_id.expect_local();
373+
372374
// (Mir-)Borrowck uses `mir_validated`, so we have to force it to
373375
// execute before we can steal.
374-
tcx.ensure().mir_borrowck(def_id.expect_local());
376+
tcx.ensure().mir_borrowck(def_id);
375377

376378
let (body, _) = tcx.mir_validated(def_id);
377379
let mut body = body.steal();
@@ -387,7 +389,9 @@ fn promoted_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &IndexVec<Promoted, Body<'_>>
387389
return tcx.intern_promoted(IndexVec::new());
388390
}
389391

390-
tcx.ensure().mir_borrowck(def_id.expect_local());
392+
let def_id = def_id.expect_local();
393+
394+
tcx.ensure().mir_borrowck(def_id);
391395
let (_, promoted) = tcx.mir_validated(def_id);
392396
let mut promoted = promoted.steal();
393397

0 commit comments

Comments
 (0)