Skip to content

Commit fb4380b

Browse files
committed
Queryify const_is_rvalue_promotable_to_static
1 parent 05b2081 commit fb4380b

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

src/librustc/middle/cstore.rs

-4
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,6 @@ pub trait CrateStore {
249249
// misc. metadata
250250
fn item_body<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
251251
-> &'tcx hir::Body;
252-
fn const_is_rvalue_promotable_to_static(&self, def: DefId) -> bool;
253252

254253
fn is_item_mir_available(&self, def: DefId) -> bool;
255254

@@ -399,9 +398,6 @@ impl CrateStore for DummyCrateStore {
399398
-> &'tcx hir::Body {
400399
bug!("item_body")
401400
}
402-
fn const_is_rvalue_promotable_to_static(&self, def: DefId) -> bool {
403-
bug!("const_is_rvalue_promotable_to_static")
404-
}
405401

406402
fn is_item_mir_available(&self, def: DefId) -> bool {
407403
bug!("is_item_mir_available")

src/librustc/ty/maps.rs

+8
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,13 @@ impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
298298
}
299299
}
300300

301+
impl<'tcx> QueryDescription for queries::const_is_rvalue_promotable_to_static<'tcx> {
302+
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
303+
format!("const checking if rvalue is promotable to static `{}`",
304+
tcx.item_path_str(def_id))
305+
}
306+
}
307+
301308
macro_rules! define_maps {
302309
(<$tcx:tt>
303310
$($(#[$attr:meta])*
@@ -587,6 +594,7 @@ define_maps! { <'tcx>
587594
[] def_span: DefSpan(DefId) -> Span,
588595

589596
[] item_body_nested_bodies: metadata_dep_node(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
597+
[] const_is_rvalue_promotable_to_static: metadata_dep_node(DefId) -> bool,
590598
}
591599

592600
fn coherent_trait_dep_node((_, def_id): (CrateNum, DefId)) -> DepNode<DefId> {

src/librustc_metadata/cstore_impl.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,10 @@ provide! { <'tcx> tcx, def_id, cdata
122122

123123
Rc::new(map)
124124
}
125+
const_is_rvalue_promotable_to_static => {
126+
cdata.entry(def_id.index).ast.expect("const item missing `ast`")
127+
.decode(cdata).rvalue_promotable_to_static
128+
}
125129
}
126130

127131
impl CrateStore for cstore::CStore {
@@ -439,11 +443,6 @@ impl CrateStore for cstore::CStore {
439443
self.get_crate_data(def_id.krate).item_body(tcx, def_id.index)
440444
}
441445

442-
fn const_is_rvalue_promotable_to_static(&self, def: DefId) -> bool {
443-
self.dep_graph.read(DepNode::MetaData(def));
444-
self.get_crate_data(def.krate).const_is_rvalue_promotable_to_static(def.index)
445-
}
446-
447446
fn is_item_mir_available(&self, def: DefId) -> bool {
448447
self.dep_graph.read(DepNode::MetaData(def));
449448
self.get_crate_data(def.krate).is_item_mir_available(def.index)

src/librustc_metadata/decoder.rs

-5
Original file line numberDiff line numberDiff line change
@@ -772,11 +772,6 @@ impl<'a, 'tcx> CrateMetadata {
772772
tcx.alloc_tables(ast.tables.decode((self, tcx)))
773773
}
774774

775-
pub fn const_is_rvalue_promotable_to_static(&self, id: DefIndex) -> bool {
776-
self.entry(id).ast.expect("const item missing `ast`")
777-
.decode(self).rvalue_promotable_to_static
778-
}
779-
780775
pub fn is_item_mir_available(&self, id: DefIndex) -> bool {
781776
!self.is_proc_macro(id) &&
782777
self.maybe_entry(id).and_then(|item| item.decode(self).mir).is_some()

src/librustc_passes/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ fn check_expr<'a, 'tcx>(v: &mut CheckCrateVisitor<'a, 'tcx>, e: &hir::Expr, node
336336
_ => false
337337
}
338338
} else {
339-
v.tcx.sess.cstore.const_is_rvalue_promotable_to_static(did)
339+
v.tcx.const_is_rvalue_promotable_to_static(did)
340340
};
341341
}
342342
_ => {

0 commit comments

Comments
 (0)