item_attrs
This commit is contained in:
parent
4d7c0b68cf
commit
a12a55f519
@ -157,6 +157,7 @@ pub enum DepNode<D: Clone + Debug> {
|
|||||||
ItemBodyNestedBodies(D),
|
ItemBodyNestedBodies(D),
|
||||||
ConstIsRvaluePromotableToStatic(D),
|
ConstIsRvaluePromotableToStatic(D),
|
||||||
IsMirAvailable(D),
|
IsMirAvailable(D),
|
||||||
|
ItemAttrs(D),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<D: Clone + Debug> DepNode<D> {
|
impl<D: Clone + Debug> DepNode<D> {
|
||||||
@ -267,6 +268,7 @@ impl<D: Clone + Debug> DepNode<D> {
|
|||||||
DefSpan(ref d) => op(d).map(DefSpan),
|
DefSpan(ref d) => op(d).map(DefSpan),
|
||||||
Stability(ref d) => op(d).map(Stability),
|
Stability(ref d) => op(d).map(Stability),
|
||||||
Deprecation(ref d) => op(d).map(Deprecation),
|
Deprecation(ref d) => op(d).map(Deprecation),
|
||||||
|
ItemAttrs(ref d) => op(d).map(ItemAttrs),
|
||||||
ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies),
|
ItemBodyNestedBodies(ref d) => op(d).map(ItemBodyNestedBodies),
|
||||||
ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic),
|
ConstIsRvaluePromotableToStatic(ref d) => op(d).map(ConstIsRvaluePromotableToStatic),
|
||||||
IsMirAvailable(ref d) => op(d).map(IsMirAvailable),
|
IsMirAvailable(ref d) => op(d).map(IsMirAvailable),
|
||||||
|
@ -182,7 +182,6 @@ pub trait CrateStore {
|
|||||||
fn visibility(&self, def: DefId) -> ty::Visibility;
|
fn visibility(&self, def: DefId) -> ty::Visibility;
|
||||||
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
|
fn visible_parent_map<'a>(&'a self) -> ::std::cell::Ref<'a, DefIdMap<DefId>>;
|
||||||
fn item_generics_cloned(&self, def: DefId) -> ty::Generics;
|
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>;
|
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>;
|
||||||
|
|
||||||
// trait info
|
// trait info
|
||||||
@ -309,7 +308,6 @@ impl CrateStore for DummyCrateStore {
|
|||||||
}
|
}
|
||||||
fn item_generics_cloned(&self, def: DefId) -> ty::Generics
|
fn item_generics_cloned(&self, def: DefId) -> ty::Generics
|
||||||
{ bug!("item_generics_cloned") }
|
{ 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") }
|
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name> { bug!("fn_arg_names") }
|
||||||
|
|
||||||
// trait info
|
// trait info
|
||||||
|
@ -34,6 +34,7 @@ use std::ops::Deref;
|
|||||||
use std::rc::Rc;
|
use std::rc::Rc;
|
||||||
use syntax_pos::{Span, DUMMY_SP};
|
use syntax_pos::{Span, DUMMY_SP};
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
|
use syntax::ast;
|
||||||
use syntax::symbol::Symbol;
|
use syntax::symbol::Symbol;
|
||||||
|
|
||||||
pub trait Key: Clone + Hash + Eq + Debug {
|
pub trait Key: Clone + Hash + Eq + Debug {
|
||||||
@ -334,6 +335,12 @@ impl<'tcx> QueryDescription for queries::deprecation<'tcx> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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> {
|
impl<'tcx> QueryDescription for queries::item_body_nested_bodies<'tcx> {
|
||||||
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
|
fn describe(tcx: TyCtxt, def_id: DefId) -> String {
|
||||||
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
|
format!("nested item bodies of `{}`", tcx.item_path_str(def_id))
|
||||||
@ -783,6 +790,7 @@ define_maps! { <'tcx>
|
|||||||
[] def_span: DefSpan(DefId) -> Span,
|
[] def_span: DefSpan(DefId) -> Span,
|
||||||
[] stability: Stability(DefId) -> Option<attr::Stability>,
|
[] stability: Stability(DefId) -> Option<attr::Stability>,
|
||||||
[] deprecation: Deprecation(DefId) -> Option<attr::Deprecation>,
|
[] 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>>,
|
[] item_body_nested_bodies: ItemBodyNestedBodies(DefId) -> Rc<BTreeMap<hir::BodyId, hir::Body>>,
|
||||||
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
|
[] const_is_rvalue_promotable_to_static: ConstIsRvaluePromotableToStatic(DefId) -> bool,
|
||||||
[] is_mir_available: IsMirAvailable(DefId) -> bool,
|
[] is_mir_available: IsMirAvailable(DefId) -> bool,
|
||||||
|
@ -2357,7 +2357,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
|
|||||||
if let Some(id) = self.hir.as_local_node_id(did) {
|
if let Some(id) = self.hir.as_local_node_id(did) {
|
||||||
Attributes::Borrowed(self.hir.attrs(id))
|
Attributes::Borrowed(self.hir.attrs(id))
|
||||||
} else {
|
} else {
|
||||||
Attributes::Owned(self.sess.cstore.item_attrs(did))
|
Attributes::Owned(self.item_attrs(did))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -113,6 +113,7 @@ provide! { <'tcx> tcx, def_id, cdata
|
|||||||
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
|
def_span => { cdata.get_span(def_id.index, &tcx.sess) }
|
||||||
stability => { cdata.get_stability(def_id.index) }
|
stability => { cdata.get_stability(def_id.index) }
|
||||||
deprecation => { cdata.get_deprecation(def_id.index) }
|
deprecation => { cdata.get_deprecation(def_id.index) }
|
||||||
|
item_attrs => { cdata.get_item_attrs(def_id.index) }
|
||||||
item_body_nested_bodies => {
|
item_body_nested_bodies => {
|
||||||
let map: BTreeMap<_, _> = cdata.entry(def_id.index).ast.into_iter().flat_map(|ast| {
|
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))
|
ast.decode(cdata).nested_bodies.decode(cdata).map(|body| (body.id(), body))
|
||||||
@ -145,12 +146,6 @@ impl CrateStore for cstore::CStore {
|
|||||||
self.get_crate_data(def.krate).get_generics(def.index)
|
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>
|
fn fn_arg_names(&self, did: DefId) -> Vec<ast::Name>
|
||||||
{
|
{
|
||||||
// FIXME(#38501) We've skipped a `read` on the `HirBody` of
|
// FIXME(#38501) We've skipped a `read` on the `HirBody` of
|
||||||
|
Loading…
Reference in New Issue
Block a user