mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 16:24:46 +00:00
Remove hir::ImplItem::attrs.
This commit is contained in:
parent
c49359add2
commit
5474f17011
@ -931,10 +931,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
|
||||
let has_value = true;
|
||||
let (defaultness, _) = self.lower_defaultness(i.kind.defaultness(), has_value);
|
||||
let hir_id = self.lower_node_id(i.id);
|
||||
self.lower_attrs(hir_id, &i.attrs);
|
||||
hir::ImplItem {
|
||||
def_id: hir_id.expect_owner(),
|
||||
ident: i.ident,
|
||||
attrs: self.lower_attrs(hir_id, &i.attrs),
|
||||
generics,
|
||||
vis: self.lower_visibility(&i.vis, None),
|
||||
defaultness,
|
||||
|
@ -2090,7 +2090,6 @@ pub struct ImplItem<'hir> {
|
||||
pub def_id: LocalDefId,
|
||||
pub vis: Visibility<'hir>,
|
||||
pub defaultness: Defaultness,
|
||||
pub attrs: &'hir [Attribute],
|
||||
pub generics: Generics<'hir>,
|
||||
pub kind: ImplItemKind<'hir>,
|
||||
pub span: Span,
|
||||
@ -3080,6 +3079,6 @@ mod size_asserts {
|
||||
|
||||
rustc_data_structures::static_assert_size!(super::Item<'static>, 200);
|
||||
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::ImplItem<'static>, 152);
|
||||
rustc_data_structures::static_assert_size!(super::ForeignItem<'static>, 136);
|
||||
}
|
||||
|
@ -988,16 +988,8 @@ pub fn walk_trait_item_ref<'v, V: Visitor<'v>>(visitor: &mut V, trait_item_ref:
|
||||
|
||||
pub fn walk_impl_item<'v, V: Visitor<'v>>(visitor: &mut V, impl_item: &'v ImplItem<'v>) {
|
||||
// N.B., deliberately force a compilation error if/when new fields are added.
|
||||
let ImplItem {
|
||||
def_id: _,
|
||||
ident,
|
||||
ref vis,
|
||||
ref defaultness,
|
||||
attrs: _,
|
||||
ref generics,
|
||||
ref kind,
|
||||
span: _,
|
||||
} = *impl_item;
|
||||
let ImplItem { def_id: _, ident, ref vis, ref defaultness, ref generics, ref kind, span: _ } =
|
||||
*impl_item;
|
||||
|
||||
visitor.visit_ident(ident);
|
||||
visitor.visit_vis(vis);
|
||||
|
@ -152,22 +152,13 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for TraitItem<'_> {
|
||||
|
||||
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for ImplItem<'_> {
|
||||
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
|
||||
let ImplItem {
|
||||
def_id: _,
|
||||
ident,
|
||||
ref vis,
|
||||
defaultness,
|
||||
ref attrs,
|
||||
ref generics,
|
||||
ref kind,
|
||||
span,
|
||||
} = *self;
|
||||
let ImplItem { def_id: _, ident, ref vis, defaultness, ref generics, ref kind, span } =
|
||||
*self;
|
||||
|
||||
hcx.hash_hir_item_like(|hcx| {
|
||||
ident.name.hash_stable(hcx, hasher);
|
||||
vis.hash_stable(hcx, hasher);
|
||||
defaultness.hash_stable(hcx, hasher);
|
||||
attrs.hash_stable(hcx, hasher);
|
||||
generics.hash_stable(hcx, hasher);
|
||||
kind.hash_stable(hcx, hasher);
|
||||
span.hash_stable(hcx, hasher);
|
||||
|
@ -988,7 +988,7 @@ impl<'a> State<'a> {
|
||||
self.ann.pre(self, AnnNode::SubItem(ii.hir_id()));
|
||||
self.hardbreak_if_not_bol();
|
||||
self.maybe_print_comment(ii.span.lo());
|
||||
self.print_outer_attributes(&ii.attrs);
|
||||
self.print_outer_attributes(self.attrs(ii.hir_id()));
|
||||
self.print_defaultness(ii.defaultness);
|
||||
|
||||
match ii.kind {
|
||||
|
@ -1067,6 +1067,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
match impl_item.kind {
|
||||
hir::ImplItemKind::Const(ref ty, body) => {
|
||||
let body = self.tcx.hir().body(body);
|
||||
let attrs = self.tcx.hir().attrs(impl_item.hir_id());
|
||||
self.process_assoc_const(
|
||||
impl_item.hir_id(),
|
||||
impl_item.ident,
|
||||
@ -1074,7 +1075,7 @@ impl<'tcx> DumpVisitor<'tcx> {
|
||||
Some(&body.value),
|
||||
impl_id,
|
||||
&impl_item.vis,
|
||||
&impl_item.attrs,
|
||||
attrs,
|
||||
);
|
||||
}
|
||||
hir::ImplItemKind::Fn(ref sig, body) => {
|
||||
|
@ -426,9 +426,9 @@ impl<'tcx> SaveContext<'tcx> {
|
||||
let trait_id = self.tcx.trait_id_of_impl(impl_id);
|
||||
let mut docs = String::new();
|
||||
let mut attrs = vec![];
|
||||
if let Some(Node::ImplItem(item)) = hir.find(hir_id) {
|
||||
docs = self.docs_for_attrs(&item.attrs);
|
||||
attrs = item.attrs.to_vec();
|
||||
if let Some(Node::ImplItem(_)) = hir.find(hir_id) {
|
||||
attrs = self.tcx.hir().attrs(hir_id).to_vec();
|
||||
docs = self.docs_for_attrs(&attrs);
|
||||
}
|
||||
|
||||
let mut decl_id = None;
|
||||
|
@ -353,7 +353,7 @@ impl<'tcx> LateLintPass<'tcx> for Attributes {
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx ImplItem<'_>) {
|
||||
if is_relevant_impl(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()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,8 @@ impl<'tcx> LateLintPass<'tcx> for DocMarkdown {
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
|
||||
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 self.in_trait_impl || in_external_macro(cx.tcx.sess, item.span) {
|
||||
return;
|
||||
}
|
||||
|
@ -312,11 +312,12 @@ impl<'tcx> LateLintPass<'tcx> for Functions {
|
||||
if is_public && trait_ref_of_method(cx, item.hir_id()).is_none() {
|
||||
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);
|
||||
} else if is_public
|
||||
&& !is_proc_macro(cx.sess(), &item.attrs)
|
||||
&& !is_proc_macro(cx.sess(), attrs)
|
||||
&& trait_ref_of_method(cx, item.hir_id()).is_none()
|
||||
{
|
||||
check_must_use_candidate(
|
||||
|
@ -183,7 +183,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
|
||||
}
|
||||
|
||||
let (article, desc) = cx.tcx.article_and_description(impl_item.def_id.to_def_id());
|
||||
self.check_missing_docs_attrs(cx, &impl_item.attrs, impl_item.span, article, desc);
|
||||
let attrs = cx.tcx.hir().attrs(impl_item.hir_id());
|
||||
self.check_missing_docs_attrs(cx, attrs, impl_item.span, article, desc);
|
||||
}
|
||||
|
||||
fn check_struct_field(&mut self, cx: &LateContext<'tcx>, sf: &'tcx hir::StructField<'_>) {
|
||||
|
@ -161,6 +161,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
|
||||
}
|
||||
}
|
||||
|
||||
check_missing_inline_attrs(cx, &impl_item.attrs, impl_item.span, desc);
|
||||
let attrs = cx.tcx.hir().attrs(impl_item.hir_id());
|
||||
check_missing_inline_attrs(cx, attrs, impl_item.span, desc);
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ impl<'tcx> LateLintPass<'tcx> for DeepCodeInspector {
|
||||
}
|
||||
|
||||
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx hir::ImplItem<'_>) {
|
||||
if !has_attr(cx.sess(), &item.attrs) {
|
||||
if !has_attr(cx.sess(), cx.tcx.hir().attrs(item.hir_id())) {
|
||||
return;
|
||||
}
|
||||
println!("impl item `{}`", item.ident.name);
|
||||
|
Loading…
Reference in New Issue
Block a user