Remove hir::MacroDef::attrs.

This commit is contained in:
Camille GILLOT 2021-02-18 19:34:40 +01:00
parent fd8a021757
commit c05c90275c
5 changed files with 6 additions and 7 deletions

View File

@ -221,12 +221,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
if let ItemKind::MacroDef(MacroDef { ref body, macro_rules }) = i.kind {
if !macro_rules || self.sess.contains_name(&i.attrs, sym::macro_export) {
let hir_id = self.lower_node_id(i.id);
let attrs = self.lower_attrs(hir_id, &i.attrs);
self.lower_attrs(hir_id, &i.attrs);
let body = P(self.lower_mac_args(body));
self.exported_macros.push(hir::MacroDef {
ident,
vis,
attrs,
def_id: hir_id.expect_owner(),
span: i.span,
ast: MacroDef { body, macro_rules },

View File

@ -768,7 +768,6 @@ impl Crate<'_> {
pub struct MacroDef<'hir> {
pub ident: Ident,
pub vis: Visibility<'hir>,
pub attrs: &'hir [Attribute],
pub def_id: LocalDefId,
pub span: Span,
pub ast: ast::MacroDef,

View File

@ -206,11 +206,10 @@ impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for Item<'_> {
impl<HirCtx: crate::HashStableContext> HashStable<HirCtx> for MacroDef<'_> {
fn hash_stable(&self, hcx: &mut HirCtx, hasher: &mut StableHasher) {
let MacroDef { ident, ref attrs, def_id: _, ref ast, ref vis, span } = *self;
let MacroDef { ident, def_id: _, ref ast, ref vis, span } = *self;
hcx.hash_hir_item_like(|hcx| {
ident.name.hash_stable(hcx, hasher);
attrs.hash_stable(hcx, hasher);
ast.hash_stable(hcx, hasher);
vis.hash_stable(hcx, hasher);
span.hash_stable(hcx, hasher);

View File

@ -568,7 +568,8 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
self.check_missing_docs_attrs(cx, hir::CRATE_HIR_ID, krate.item.span, "the", "crate");
for macro_def in krate.exported_macros {
let has_doc = macro_def.attrs.iter().any(|a| has_doc(cx.sess(), a));
let attrs = cx.tcx.hir().attrs(macro_def.hir_id());
let has_doc = attrs.iter().any(|a| has_doc(cx.sess(), a));
if !has_doc {
cx.struct_span_lint(
MISSING_DOCS,

View File

@ -881,7 +881,8 @@ impl Visitor<'tcx> for EmbargoVisitor<'tcx> {
fn visit_macro_def(&mut self, md: &'tcx hir::MacroDef<'tcx>) {
// Non-opaque macros cannot make other items more accessible than they already are.
if attr::find_transparency(&self.tcx.sess, &md.attrs, md.ast.macro_rules).0
let attrs = self.tcx.hir().attrs(md.hir_id());
if attr::find_transparency(&self.tcx.sess, &attrs, md.ast.macro_rules).0
!= Transparency::Opaque
{
// `#[macro_export]`-ed `macro_rules!` are `Public` since they