diff options
| author | Taylor Cramer <cramertaylorj@gmail.com> | 2017-04-28 01:08:48 -0700 |
|---|---|---|
| committer | Taylor Cramer <cramertj@google.com> | 2017-05-01 10:24:10 -0700 |
| commit | fb4380b12db03264afbd085e1f654b0a38ecc3f2 (patch) | |
| tree | 515608c3683506ec349628bde2d17c7d6eaca138 | |
| parent | 05b2081e2344cf396427451572f8c3b6e2331f6b (diff) | |
| download | rust-fb4380b12db03264afbd085e1f654b0a38ecc3f2.tar.gz rust-fb4380b12db03264afbd085e1f654b0a38ecc3f2.zip | |
Queryify const_is_rvalue_promotable_to_static
| -rw-r--r-- | src/librustc/middle/cstore.rs | 4 | ||||
| -rw-r--r-- | src/librustc/ty/maps.rs | 8 | ||||
| -rw-r--r-- | src/librustc_metadata/cstore_impl.rs | 9 | ||||
| -rw-r--r-- | src/librustc_metadata/decoder.rs | 5 | ||||
| -rw-r--r-- | src/librustc_passes/consts.rs | 2 |
5 files changed, 13 insertions, 15 deletions
diff --git a/src/librustc/middle/cstore.rs b/src/librustc/middle/cstore.rs index d327b3ed9d3..3cb827cdf6c 100644 --- a/src/librustc/middle/cstore.rs +++ b/src/librustc/middle/cstore.rs @@ -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") diff --git a/src/librustc/ty/maps.rs b/src/librustc/ty/maps.rs index a7f1c556f03..57a69c5fa0b 100644 --- a/src/librustc/ty/maps.rs +++ b/src/librustc/ty/maps.rs @@ -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> { diff --git a/src/librustc_metadata/cstore_impl.rs b/src/librustc_metadata/cstore_impl.rs index 067fe246d94..a492e2afa4c 100644 --- a/src/librustc_metadata/cstore_impl.rs +++ b/src/librustc_metadata/cstore_impl.rs @@ -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) diff --git a/src/librustc_metadata/decoder.rs b/src/librustc_metadata/decoder.rs index 9da9829b61d..2317c156b41 100644 --- a/src/librustc_metadata/decoder.rs +++ b/src/librustc_metadata/decoder.rs @@ -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() diff --git a/src/librustc_passes/consts.rs b/src/librustc_passes/consts.rs index f275b4cafaf..6866fe80768 100644 --- a/src/librustc_passes/consts.rs +++ b/src/librustc_passes/consts.rs @@ -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) }; } _ => { |
