Queryify is_item_mir_available
This commit is contained in:
parent
fb4380b12d
commit
daa0094eb7
6 changed files with 16 additions and 20 deletions
|
|
@ -250,8 +250,6 @@ pub trait CrateStore {
|
|||
fn item_body<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> &'tcx hir::Body;
|
||||
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool;
|
||||
|
||||
// This is basically a 1-based range of ints, which is a little
|
||||
// silly - I may fix that.
|
||||
fn crates(&self) -> Vec<CrateNum>;
|
||||
|
|
@ -399,10 +397,6 @@ impl CrateStore for DummyCrateStore {
|
|||
bug!("item_body")
|
||||
}
|
||||
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool {
|
||||
bug!("is_item_mir_available")
|
||||
}
|
||||
|
||||
// This is basically a 1-based range of ints, which is a little
|
||||
// silly - I may fix that.
|
||||
fn crates(&self) -> Vec<CrateNum> { vec![] }
|
||||
|
|
|
|||
|
|
@ -305,6 +305,13 @@ impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'t
|
|||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::is_item_mir_available<'tcx> {
|
||||
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
|
||||
format!("checking if item is mir available: `{}`",
|
||||
tcx.item_path_str(def_id))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! define_maps {
|
||||
(<$tcx:tt>
|
||||
$($(#[$attr:meta])*
|
||||
|
|
@ -595,6 +602,7 @@ define_maps! { <'tcx>
|
|||
|
||||
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
|
||||
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
|
||||
[] is_item_mir_available: metadata_dep_node(DefId) -> bool,
|
||||
}
|
||||
|
||||
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
|
||||
|
|
|
|||
|
|
@ -2332,7 +2332,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||
return None;
|
||||
}
|
||||
|
||||
if !did.is_local() && !self.sess.cstore.is_item_mir_available(did) {
|
||||
if !did.is_local() && !self.is_item_mir_available(did) {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -126,6 +126,10 @@ provide! { <'tcx> tcx, def_id, cdata
|
|||
cdata.entry(def_id.index).ast.expect("const item missing `ast`")
|
||||
.decode(cdata).rvalue_promotable_to_static
|
||||
}
|
||||
is_item_mir_available => {
|
||||
!cdata.is_proc_macro(def_id.index) &&
|
||||
cdata.maybe_entry(def_id.index).and_then(|item| item.decode(cdata).mir).is_some()
|
||||
}
|
||||
}
|
||||
|
||||
impl CrateStore for cstore::CStore {
|
||||
|
|
@ -443,11 +447,6 @@ impl CrateStore for cstore::CStore {
|
|||
self.get_crate_data(def_id.krate).item_body(tcx, def_id.index)
|
||||
}
|
||||
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool {
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
self.get_crate_data(def.krate).is_item_mir_available(def.index)
|
||||
}
|
||||
|
||||
fn crates(&self) -> Vec<CrateNum>
|
||||
{
|
||||
let mut result = vec![];
|
||||
|
|
|
|||
|
|
@ -441,11 +441,11 @@ impl<'tcx> EntryKind<'tcx> {
|
|||
}
|
||||
|
||||
impl<'a, 'tcx> CrateMetadata {
|
||||
fn is_proc_macro(&self, id: DefIndex) -> bool {
|
||||
pub fn is_proc_macro(&self, id: DefIndex) -> bool {
|
||||
self.proc_macros.is_some() && id != CRATE_DEF_INDEX
|
||||
}
|
||||
|
||||
fn maybe_entry(&self, item_id: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
|
||||
pub fn maybe_entry(&self, item_id: DefIndex) -> Option<Lazy<Entry<'tcx>>> {
|
||||
assert!(!self.is_proc_macro(item_id));
|
||||
self.root.index.lookup(self.blob.raw_bytes(), item_id)
|
||||
}
|
||||
|
|
@ -772,11 +772,6 @@ impl<'a, 'tcx> CrateMetadata {
|
|||
tcx.alloc_tables(ast.tables.decode((self, tcx)))
|
||||
}
|
||||
|
||||
pub fn is_item_mir_available(&self, id: DefIndex) -> bool {
|
||||
!self.is_proc_macro(id) &&
|
||||
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()
|
||||
}
|
||||
|
||||
pub fn maybe_get_item_mir(&self,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
id: DefIndex)
|
||||
|
|
|
|||
|
|
@ -659,7 +659,7 @@ fn should_trans_locally<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &Instan
|
|||
// in this crate
|
||||
false
|
||||
} else {
|
||||
if !tcx.sess.cstore.is_item_mir_available(def_id) {
|
||||
if !tcx.is_item_mir_available(def_id) {
|
||||
bug!("Cannot create local trans-item for {:?}", def_id)
|
||||
}
|
||||
true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue