Queryify const_is_rvalue_promotable_to_static
This commit is contained in:
parent
05b2081e23
commit
fb4380b12d
@ -249,7 +249,6 @@ pub trait CrateStore {
|
||||
// misc. metadata
|
||||
fn item_body<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
|
||||
-> &'tcx hir::Body;
|
||||
fn const_is_rvalue_promotable_to_static(&self, def: DefId) -> bool;
|
||||
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool;
|
||||
|
||||
@ -399,9 +398,6 @@ impl CrateStore for DummyCrateStore {
|
||||
-> &'tcx hir::Body {
|
||||
bug!("item_body")
|
||||
}
|
||||
fn const_is_rvalue_promotable_to_static(&self, def: DefId) -> bool {
|
||||
bug!("const_is_rvalue_promotable_to_static")
|
||||
}
|
||||
|
||||
fn is_item_mir_available(&self, def: DefId) -> bool {
|
||||
bug!("is_item_mir_available")
|
||||
|
@ -298,6 +298,13 @@ impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
|
||||
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
|
||||
format!("const checking if rvalue is promotable to static `{}`",
|
||||
tcx.item_path_str(def_id))
|
||||
}
|
||||
}
|
||||
|
||||
macro_rules! define_maps {
|
||||
(<$tcx:tt>
|
||||
$($(#[$attr:meta])*
|
||||
@ -587,6 +594,7 @@ define_maps! { <'tcx>
|
||||
[] def_span: DefSpan(DefId) -> Span,
|
||||
|
||||
[] 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,
|
||||
}
|
||||
|
||||
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {
|
||||
|
@ -122,6 +122,10 @@ provide! { <'tcx> tcx, def_id, cdata
|
||||
|
||||
Rc::new(map)
|
||||
}
|
||||
const_is_rvalue_promotable_to_static => {
|
||||
cdata.entry(def_id.index).ast.expect("const item missing `ast`")
|
||||
.decode(cdata).rvalue_promotable_to_static
|
||||
}
|
||||
}
|
||||
|
||||
impl CrateStore for cstore::CStore {
|
||||
@ -439,11 +443,6 @@ impl CrateStore for cstore::CStore {
|
||||
self.get_crate_data(def_id.krate).item_body(tcx, def_id.index)
|
||||
}
|
||||
|
||||
fn const_is_rvalue_promotable_to_static(&self, def: DefId) -> bool {
|
||||
self.dep_graph.read(DepNode::MetaData(def));
|
||||
self.get_crate_data(def.krate).const_is_rvalue_promotable_to_static(def.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)
|
||||
|
@ -772,11 +772,6 @@ impl<'a, 'tcx> CrateMetadata {
|
||||
tcx.alloc_tables(ast.tables.decode((self, tcx)))
|
||||
}
|
||||
|
||||
pub fn const_is_rvalue_promotable_to_static(&self, id: DefIndex) -> bool {
|
||||
self.entry(id).ast.expect("const item missing `ast`")
|
||||
.decode(self).rvalue_promotable_to_static
|
||||
}
|
||||
|
||||
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()
|
||||
|
@ -336,7 +336,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
|
||||
_ => false
|
||||
}
|
||||
} else {
|
||||
v.tcx.sess.cstore.const_is_rvalue_promotable_to_static(did)
|
||||
v.tcx.const_is_rvalue_promotable_to_static(did)
|
||||
};
|
||||
}
|
||||
_ => {
|
||||
|
Loading…
Reference in New Issue
Block a user