]> git.lizzy.rs Git - rust.git/commitdiff
Queryify const_is_rvalue_promotable_to_static
authorTaylor Cramer <cramertaylorj@gmail.com>
Fri, 28 Apr 2017 08:08:48 +0000 (01:08 -0700)
committerTaylor Cramer <cramertj@google.com>
Mon, 1 May 2017 17:24:10 +0000 (10:24 -0700)
src/librustc/middle/cstore.rs
src/librustc/ty/maps.rs
src/librustc_metadata/cstore_impl.rs
src/librustc_metadata/decoder.rs
src/librustc_passes/consts.rs

index d327b3ed9d3246ee58432c0d044d24a86a327dc3..3cb827cdf6c3236c3aa22d3472951d8889b1016d 100644 (file)
@@ -249,7 +249,6 @@ fn retrace_path(&self,
     // 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 @@ fn item_body<'a, 'tcx>(&self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def: DefId)
                            -> &'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")
index a7f1c556f03f1dda6c1dc25913d0a0f0ff4b92a2..57a69c5fa0bb0cbe9d78d9afcddf9d2ab1127e8c 100644 (file)
@@ -298,6 +298,13 @@ fn describe(tcx: TyCtxt, def_id: DefId) -> String {
     }
 }
 
+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 @@ fn default() -> Self {
     [] 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> {
index 067fe246d946d517112771528c63c373b4ed68f8..a492e2afa4c7a77c056fce5808279b5284085bc4 100644 (file)
@@ -122,6 +122,10 @@ pub fn provide<$lt>(providers: &mut Providers<$lt>) {
 
         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 @@ fn item_body<'a, 'tcx>(&self,
         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)
index 9da9829b61dccfd02a9c51106f77b9df2f85c297..2317c156b4192ba4e0753ff428d59605fe3f0531 100644 (file)
@@ -772,11 +772,6 @@ pub fn item_body_tables(&self,
         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()
index f275b4cafaf93760763533795312a7af824d0a30..6866fe807684a816f591688f15b15b9ebf445281 100644 (file)
@@ -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)
                     };
                 }
                 _ => {