Skip to content

Commit

Permalink
Use LocalDefId in mir_built query
Browse files Browse the repository at this point in the history
  • Loading branch information
marmeladema committed Apr 27, 2020
1 parent abd31ad commit f2f0478
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/librustc_middle/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ rustc_queries! {

/// Fetch the MIR for a given `DefId` right after it's built - this includes
/// unreachable code.
query mir_built(_: DefId) -> &'tcx Steal<mir::Body<'tcx>> {
query mir_built(_: LocalDefId) -> &'tcx Steal<mir::Body<'tcx>> {
desc { "building MIR for" }
}

Expand Down
10 changes: 7 additions & 3 deletions src/librustc_mir/transform/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,17 +211,21 @@ fn mir_const_qualif(tcx: TyCtxt<'_>, def_id: DefId) -> ConstQualifs {
}

fn mir_const(tcx: TyCtxt<'_>, def_id: DefId) -> &Steal<Body<'_>> {
let def_id = def_id.expect_local();

// Unsafety check uses the raw mir, so make sure it is run
let _ = tcx.unsafety_check_result(def_id.expect_local());
let _ = tcx.unsafety_check_result(def_id);

let mut body = tcx.mir_built(def_id).steal();

util::dump_mir(tcx, None, "mir_map", &0, MirSource::item(def_id), &body, |_, _| Ok(()));
util::dump_mir(tcx, None, "mir_map", &0, MirSource::item(def_id.to_def_id()), &body, |_, _| {
Ok(())
});

run_passes(
tcx,
&mut body,
InstanceDef::Item(def_id),
InstanceDef::Item(def_id.to_def_id()),
None,
MirPhase::Const,
&[&[
Expand Down
4 changes: 2 additions & 2 deletions src/librustc_mir_build/build/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ use rustc_target::spec::PanicStrategy;

use super::lints;

crate fn mir_built(tcx: TyCtxt<'_>, def_id: DefId) -> &ty::steal::Steal<Body<'_>> {
tcx.alloc_steal_mir(mir_build(tcx, def_id.expect_local()))
crate fn mir_built(tcx: TyCtxt<'_>, def_id: LocalDefId) -> &ty::steal::Steal<Body<'_>> {
tcx.alloc_steal_mir(mir_build(tcx, def_id))
}

/// Construct the MIR for a given `DefId`.
Expand Down

0 comments on commit f2f0478

Please sign in to comment.