]> git.lizzy.rs Git - rust.git/commitdiff
item_attrs
authorachernyak <artemchernyak@gmail.com>
Wed, 3 May 2017 13:40:32 +0000 (08:40 -0500)
committerachernyak <artemchernyak@gmail.com>
Wed, 3 May 2017 13:40:32 +0000 (08:40 -0500)
src/librustc/dep_graph/dep_node.rs
src/librustc/middle/cstore.rs
src/librustc/ty/maps.rs
src/librustc/ty/mod.rs
src/librustc_metadata/cstore_impl.rs

index 1c71079e94b271b97d09c5202b7a9033c8c9da26..fb8678ce93eae793c9dca06d04ee682542bb7654 100644 (file)
@@ -157,6 +157,7 @@ pub enum DepNode<D: Clone + Debug> {
     ItemBodyNestedBodies(D),
     ConstIsRvaluePromotableToStatic(D),
     IsMirAvailable(D),
+    ItemAttrs(D),
 }
 
 impl<D: Clone + Debug> DepNode<D> {
@@ -267,6 +268,7 @@ pub fn map_def<E, OP>(&self, mut op: OP) -> Option<DepNode<E>>
             DefSpan(ref d) => op(d).map(DefSpan),
             Stability(ref d) => op(d).map(Stability),
             Deprecation(ref d) => op(d).map(Deprecation),
+            ItemAttrs(ref d) => op(d).map(ItemAttrs),
             ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies),
             ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic),
             IsMirAvailable(ref d) => op(d).map(IsMirAvailable),
index 303c5059e7cf3d6136445d2a076dbe601243aeb4..e30b4b2818e5e22e26503a19c6c3e9fa9391e7ba 100644 (file)
@@ -182,7 +182,6 @@ pub trait CrateStore {
     fn visibility(&self, def: DefId) -> ty::Visibility;
     fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
     fn item_generics_cloned(&self, def: DefId) -> ty::Generics;
-    fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>;
     fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
 
     // trait info
@@ -309,7 +308,6 @@ fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>> {
     }
     fn item_generics_cloned(&self, def: DefId) -> ty::Generics
         { bug!("item_generics_cloned") }
-    fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> { bug!("item_attrs") }
     fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
 
     // trait info
index 513240a4ec345c950034a25f21297ea45f73e621..948df617867512e0e7179b7b35c6fe5effdaedf1 100644 (file)
@@ -34,6 +34,7 @@
 use std::rc::Rc;
 use syntax_pos::{Span, DUMMY_SP};
 use syntax::attr;
+use syntax::ast;
 use syntax::symbol::Symbol;
 
 pub trait Key: Clone + Hash + Eq + Debug {
@@ -334,6 +335,12 @@ fn describe(_: TyCtxt, _: DefId) -> String {
     }
 }
 
+impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
+    fn describe(_: TyCtxt, _: DefId) -> String {
+        bug!("item_attrs")
+    }
+}
+
 impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
     fn describe(tcx: TyCtxt, def_id: DefId) -> String {
         format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
@@ -783,6 +790,7 @@ fn default() -> Self {
     [] def_span: DefSpan(DefId) -> Span,
     [] stability: Stability(DefId) -> Option<attr::Stability>,
     [] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
+    [] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
     [] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
     [] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
     [] is_mir_available: IsMirAvailable(DefId) -> bool,
index 55466b1f36dac513c687a61708e0d3ef38d6e81a..3cc250f0814efa351fdc7a4d90990cdf27d84c17 100644 (file)
@@ -2357,7 +2357,7 @@ pub fn get_attrs(self, did: DefId) -> Attributes<'gcx> {
         if let Some(id) = self.hir.as_local_node_id(did) {
             Attributes::Borrowed(self.hir.attrs(id))
         } else {
-            Attributes::Owned(self.sess.cstore.item_attrs(did))
+            Attributes::Owned(self.item_attrs(did))
         }
     }
 
index a1794ec2d82cace665364da1860a24d09c90c9bb..c7a52922e2a0997224f41fffc873e5c0fab60446 100644 (file)
@@ -113,6 +113,7 @@ pub fn provide<$lt>(providers: &mut Providers<$lt>) {
     def_span => { cdata.get_span(def_id.index, &tcx.sess) }
     stability => { cdata.get_stability(def_id.index) }
     deprecation => { cdata.get_deprecation(def_id.index) }
+    item_attrs => { cdata.get_item_attrs(def_id.index) }
     item_body_nested_bodies => {
         let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| {
             ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body))
@@ -145,12 +146,6 @@ fn item_generics_cloned(&self, def: DefId) -> ty::Generics {
         self.get_crate_data(def.krate).get_generics(def.index)
     }
 
-    fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>
-    {
-        self.dep_graph.read(DepNode::MetaData(def_id));
-        self.get_crate_data(def_id.krate).get_item_attrs(def_id.index)
-    }
-
     fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>
     {
         // FIXME(#38501) We've skipped a `read` on the `HirBody` of