Skip to content

Commit 58ba925

Browse files
committed
Accept LocalDefId as key for mir_validated query
1 parent 28e3022 commit 58ba925

File tree

4 files changed

+20
-12
lines changed

4 files changed

+20
-12
lines changed

src/librustc_builtin_macros/format.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,9 @@ impl<'a, 'b> Context<'a, 'b> {
410410
.iter()
411411
.filter(|fmt| fmt.precision_span.is_some())
412412
.count();
413-
e.span_label(span, &format!(
413+
e.span_label(
414+
span,
415+
&format!(
414416
"this precision flag adds an extra required argument at position {}, \
415417
which is why there {} expected",
416418
pos,
@@ -419,7 +421,8 @@ impl<'a, 'b> Context<'a, 'b> {
419421
} else {
420422
format!("are {} arguments", count)
421423
},
422-
));
424+
),
425+
);
423426
if let Some(arg) = self.args.get(pos) {
424427
e.span_label(
425428
arg.span,

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
@@ -238,13 +238,13 @@ fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
238238

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

247-
let mut body = tcx.mir_const(def_id).steal();
247+
let mut body = tcx.mir_const(def_id.to_def_id()).steal();
248248

249249
let mut required_consts = Vec::new();
250250
let mut required_consts_visitor = RequiredConstsVisitor::new(&mut required_consts);
@@ -257,7 +257,7 @@ fn mir_validated(
257257
run_passes(
258258
tcx,
259259
&mut body,
260-
InstanceDef::Item(def_id),
260+
InstanceDef::Item(def_id.to_def_id()),
261261
None,
262262
MirPhase::Validated,
263263
&[
@@ -274,13 +274,13 @@ fn mir_validated(
274274
fn run_optimization_passes<'tcx>(
275275
tcx: TyCtxt<'tcx>,
276276
body: &mut Body<'tcx>,
277-
def_id: DefId,
277+
def_id: LocalDefId,
278278
promoted: Option<Promoted>,
279279
) {
280280
run_passes(
281281
tcx,
282282
body,
283-
InstanceDef::Item(def_id),
283+
InstanceDef::Item(def_id.to_def_id()),
284284
promoted,
285285
MirPhase::Optimized,
286286
&[
@@ -338,9 +338,11 @@ fn optimized_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &Body<'_> {
338338
return shim::build_adt_ctor(tcx, def_id);
339339
}
340340

341+
let def_id = def_id.expect_local();
342+
341343
// (Mir-)Borrowck uses `mir_validated`, so we have to force it to
342344
// execute before we can steal.
343-
tcx.ensure().mir_borrowck(def_id.expect_local());
345+
tcx.ensure().mir_borrowck(def_id);
344346

345347
let (body, _) = tcx.mir_validated(def_id);
346348
let mut body = body.steal();
@@ -356,7 +358,9 @@ fn promoted_mir(tcx: TyCtxt<'_>, def_id: DefId) -> &IndexVec<Promoted, Body<'_>>
356358
return tcx.intern_promoted(IndexVec::new());
357359
}
358360

359-
tcx.ensure().mir_borrowck(def_id.expect_local());
361+
let def_id = def_id.expect_local();
362+
363+
tcx.ensure().mir_borrowck(def_id);
360364
let (_, promoted) = tcx.mir_validated(def_id);
361365
let mut promoted = promoted.steal();
362366

0 commit comments

Comments
 (0)