Skip to content

Commit a12a55f

Browse files
committed
item_attrs
1 parent 4d7c0b6 commit a12a55f

File tree

5 files changed

+12
-9
lines changed

5 files changed

+12
-9
lines changed

src/librustc/dep_graph/dep_node.rs

+2
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ pub enum DepNode<D: Clone + Debug> {
157157
ItemBodyNestedBodies(D),
158158
ConstIsRvaluePromotableToStatic(D),
159159
IsMirAvailable(D),
160+
ItemAttrs(D),
160161
}
161162

162163
impl<D: Clone + Debug> DepNode<D> {
@@ -267,6 +268,7 @@ impl<D: Clone + Debug> DepNode<D> {
267268
DefSpan(ref d) => op(d).map(DefSpan),
268269
Stability(ref d) => op(d).map(Stability),
269270
Deprecation(ref d) => op(d).map(Deprecation),
271+
ItemAttrs(ref d) => op(d).map(ItemAttrs),
270272
ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies),
271273
ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic),
272274
IsMirAvailable(ref d) => op(d).map(IsMirAvailable),

src/librustc/middle/cstore.rs

-2
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ pub trait CrateStore {
182182
fn visibility(&self, def: DefId) -> ty::Visibility;
183183
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
184184
fn item_generics_cloned(&self, def: DefId) -> ty::Generics;
185-
fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>;
186185
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
187186

188187
// trait info
@@ -309,7 +308,6 @@ impl CrateStore for DummyCrateStore {
309308
}
310309
fn item_generics_cloned(&self, def: DefId) -> ty::Generics
311310
{ bug!("item_generics_cloned") }
312-
fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]> { bug!("item_attrs") }
313311
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
314312

315313
// trait info

src/librustc/ty/maps.rs

+8
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use std::ops::Deref;
3434
use std::rc::Rc;
3535
use syntax_pos::{Span, DUMMY_SP};
3636
use syntax::attr;
37+
use syntax::ast;
3738
use syntax::symbol::Symbol;
3839

3940
pub trait Key: Clone + Hash + Eq + Debug {
@@ -334,6 +335,12 @@ impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
334335
}
335336
}
336337

338+
impl<'tcx> QueryDescription for queries::item_attrs<'tcx> {
339+
fn describe(_: TyCtxt, _: DefId) -> String {
340+
bug!("item_attrs")
341+
}
342+
}
343+
337344
impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
338345
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
339346
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
@@ -783,6 +790,7 @@ define_maps! { <'tcx>
783790
[] def_span: DefSpan(DefId) -> Span,
784791
[] stability: Stability(DefId) -> Option<attr::Stability>,
785792
[] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
793+
[] item_attrs: ItemAttrs(DefId) -> Rc<[ast::Attribute]>,
786794
[] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
787795
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
788796
[] is_mir_available: IsMirAvailable(DefId) -> bool,

src/librustc/ty/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2357,7 +2357,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
23572357
if let Some(id) = self.hir.as_local_node_id(did) {
23582358
Attributes::Borrowed(self.hir.attrs(id))
23592359
} else {
2360-
Attributes::Owned(self.sess.cstore.item_attrs(did))
2360+
Attributes::Owned(self.item_attrs(did))
23612361
}
23622362
}
23632363

src/librustc_metadata/cstore_impl.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ provide! { <'tcx> tcx, def_id, cdata
113113
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
114114
stability => { cdata.get_stability(def_id.index) }
115115
deprecation => { cdata.get_deprecation(def_id.index) }
116+
item_attrs => { cdata.get_item_attrs(def_id.index) }
116117
item_body_nested_bodies => {
117118
let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| {
118119
ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body))
@@ -145,12 +146,6 @@ impl CrateStore for cstore::CStore {
145146
self.get_crate_data(def.krate).get_generics(def.index)
146147
}
147148

148-
fn item_attrs(&self, def_id: DefId) -> Rc<[ast::Attribute]>
149-
{
150-
self.dep_graph.read(DepNode::MetaData(def_id));
151-
self.get_crate_data(def_id.krate).get_item_attrs(def_id.index)
152-
}
153-
154149
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>
155150
{
156151
// FIXME(#38501) We've skipped a `read` on the `HirBody` of

0 commit comments

Comments
 (0)