Remove hir::TraitItem::attrs.
This commit is contained in:
parent
4bab93a039
commit
c49359add2
@ -851,14 +851,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
AssocItemKind::MacCall(..) => panic!("macro item shouldn't exist at this point"),
|
||||
};
|
||||
|
||||
hir::TraitItem {
|
||||
def_id: trait_item_def_id,
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(hir_id, &i.attrs),
|
||||
generics,
|
||||
kind,
|
||||
span: i.span,
|
||||
}
|
||||
self.lower_attrs(hir_id, &i.attrs);
|
||||
hir::TraitItem { def_id: trait_item_def_id, ident: i.ident, generics, kind, span: i.span }
|
||||
}
|
||||
|
||||
fn lower_trait_item_ref(&mut self, i: &AssocItem) -> hir::TraitItemRef {
|
||||
|
@ -2028,7 +2028,6 @@ impl TraitItemId {
|
||||
pub struct TraitItem<'hir> {
|
||||
pub ident: Ident,
|
||||
pub def_id: LocalDefId,
|
||||
pub attrs: &'hir [Attribute],
|
||||
pub generics: Generics<'hir>,
|
||||
pub kind: TraitItemKind<'hir>,
|
||||
pub span: Span,
|
||||
@ -3080,7 +3079,7 @@ mod size_asserts {
|
||||
rustc_data_structures::static_assert_size!(super::Ty<'static>, 72);
|
||||
|
||||
rustc_data_structures::static_assert_size!(super::Item<'static>, 200);
|
||||
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 144);
|
||||
rustc_data_structures::static_assert_size!(super::TraitItem<'static>, 128);
|
||||
rustc_data_structures::static_assert_size!(super::ImplItem<'static>, 168);
|
||||
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 136);
|
||||
}
|
||||
|
@ -139,11 +139,10 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for VisibilityKind<'_>
|
||||
|
||||
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItem<'_> {
|
||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
||||
let TraitItem { def_id: _, ident, ref attrs, ref generics, ref kind, span } = *self;
|
||||
let TraitItem { def_id: _, ident, ref generics, ref kind, span } = *self;
|
||||
|
||||
hcx.hash_hir_item_like(|hcx| {
|
||||
ident.name.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
generics.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
|
@ -949,7 +949,7 @@ impl<'a> State<'a> {
|
||||
self.ann.pre(self, AnnNode::SubItem(ti.hir_id()));
|
||||
self.hardbreak_if_not_bol();
|
||||
self.maybe_print_comment(ti.span.lo());
|
||||
self.print_outer_attributes(&ti.attrs);
|
||||
self.print_outer_attributes(self.attrs(ti.hir_id()));
|
||||
match ti.kind {
|
||||
hir::TraitItemKind::Const(ref ty, default) => {
|
||||
let vis =
|
||||
|
@ -994,6 +994,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
hir::TraitItemKind::Const(ref ty, body) => {
|
||||
let body = body.map(|b| &self.tcx.hir().body(b).value);
|
||||
let respan = respan(vis_span, hir::VisibilityKind::Public);
|
||||
let attrs = self.tcx.hir().attrs(trait_item.hir_id());
|
||||
self.process_assoc_const(
|
||||
trait_item.hir_id(),
|
||||
trait_item.ident,
|
||||
@ -1001,7 +1002,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
body,
|
||||
trait_id,
|
||||
&respan,
|
||||
&trait_item.attrs,
|
||||
attrs,
|
||||
);
|
||||
}
|
||||
hir::TraitItemKind::Fn(ref sig, ref trait_fn) => {
|
||||
@ -1027,6 +1028,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
if !self.span.filter_generated(trait_item.ident.span) {
|
||||
let span = self.span_from_span(trait_item.ident.span);
|
||||
let id = id_from_def_id(trait_item.def_id.to_def_id());
|
||||
let attrs = self.tcx.hir().attrs(trait_item.hir_id());
|
||||
|
||||
self.dumper.dump_def(
|
||||
&Access { public: true, reachable: true },
|
||||
@ -1040,7 +1042,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
parent: Some(id_from_def_id(trait_id)),
|
||||
children: vec![],
|
||||
decl_id: None,
|
||||
docs: self.save_ctxt.docs_for_attrs(&trait_item.attrs),
|
||||
docs: self.save_ctxt.docs_for_attrs(attrs),
|
||||
sig: sig::assoc_type_signature(
|
||||
trait_item.hir_id(),
|
||||
trait_item.ident,
|
||||
@ -1048,10 +1050,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
default_ty.as_ref().map(|ty| &**ty),
|
||||
&self.save_ctxt,
|
||||
),
|
||||
attributes: lower_attributes(
|
||||
trait_item.attrs.to_vec(),
|
||||
&self.save_ctxt,
|
||||
),
|
||||
attributes: lower_attributes(attrs.to_vec(), &self.save_ctxt),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
@ -472,9 +472,9 @@ impl<'tcx> SaveContext<'tcx> {
|
||||
let mut docs = String::new();
|
||||
let mut attrs = vec![];
|
||||
|
||||
if let Some(Node::TraitItem(item)) = self.tcx.hir().find(hir_id) {
|
||||
docs = self.docs_for_attrs(&item.attrs);
|
||||
attrs = item.attrs.to_vec();
|
||||
if let Some(Node::TraitItem(_)) = self.tcx.hir().find(hir_id) {
|
||||
attrs = self.tcx.hir().attrs(hir_id).to_vec();
|
||||
docs = self.docs_for_attrs(&attrs);
|
||||
}
|
||||
|
||||
(
|
||||
|
@ -359,7 +359,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
|
||||
if is_relevant_trait(cx, item) {
|
||||
check_attrs(cx, item.span, item.ident.name, &item.attrs)
|
||||
check_attrs(cx, item.span, item.ident.name, cx.tcx.hir().attrs(item.hir_id()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -250,7 +250,8 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
|
||||
}
|
||||
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::TraitItem<'_>) {
|
||||
let headers = check_attrs(cx, &self.valid_idents, &item.attrs);
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
let headers = check_attrs(cx, &self.valid_idents, attrs);
|
||||
if let hir::TraitItemKind::Fn(ref sig, ..) = item.kind {
|
||||
if !in_external_macro(cx.tcx.sess, item.span) {
|
||||
lint_for_missing_headers(cx, item.hir_id(), item.span, sig, headers, None, None);
|
||||
|
@ -344,7 +344,8 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
check_result_unit_err(cx, &sig.decl, item.span, fn_header_span);
|
||||
}
|
||||
|
||||
let attr = must_use_attr(&item.attrs);
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
let attr = must_use_attr(attrs);
|
||||
if let Some(attr) = attr {
|
||||
check_needless_must_use(cx, &sig.decl, item.hir_id(), item.span, fn_header_span, attr);
|
||||
}
|
||||
@ -352,7 +353,7 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
let body = cx.tcx.hir().body(eid);
|
||||
Self::check_raw_ptr(cx, sig.header.unsafety, &sig.decl, body, item.hir_id());
|
||||
|
||||
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), &item.attrs) {
|
||||
if attr.is_none() && is_public && !is_proc_macro(cx.sess(), attrs) {
|
||||
check_must_use_candidate(
|
||||
cx,
|
||||
&sig.decl,
|
||||
|
@ -34,7 +34,8 @@ declare_lint_pass!(InlineFnWithoutBody => [INLINE_FN_WITHOUT_BODY]);
|
||||
impl<'tcx> LateLintPass<'tcx> for InlineFnWithoutBody {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx TraitItem<'_>) {
|
||||
if let TraitItemKind::Fn(_, TraitFn::Required(_)) = item.kind {
|
||||
check_attrs(cx, item.ident.name, &item.attrs);
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
check_attrs(cx, item.ident.name, attrs);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -167,7 +167,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
fn check_trait_item(&mut self, cx: &LateContext<'tcx>, trait_item: &'tcx hir::TraitItem<'_>) {
|
||||
let (article, desc) = cx.tcx.article_and_description(trait_item.def_id.to_def_id());
|
||||
|
||||
self.check_missing_docs_attrs(cx, &trait_item.attrs, trait_item.span, article, desc);
|
||||
let attrs = cx.tcx.hir().attrs(trait_item.hir_id());
|
||||
self.check_missing_docs_attrs(cx, attrs, trait_item.span, article, desc);
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
|
||||
|
@ -108,7 +108,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
// an impl is not provided
|
||||
let desc = "a default trait method";
|
||||
let item = cx.tcx.hir().trait_item(tit.id);
|
||||
check_missing_inline_attrs(cx, &item.attrs, item.span, desc);
|
||||
let attrs = cx.tcx.hir().attrs(item.hir_id());
|
||||
check_missing_inline_attrs(cx, attrs, item.span, desc);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user