1
Fork 0

Introduce new-style attribute parsers for several attributes

note: compiler compiles but librustdoc and clippy don't
This commit is contained in:
Jana Dönszelmann 2025-02-09 22:49:33 +01:00
parent dbd3b7928e
commit 7e0f5b5016
No known key found for this signature in database
50 changed files with 1519 additions and 1342 deletions

View file

@ -3,6 +3,7 @@ use std::mem;
use rustc_ast::visit::FnKind;
use rustc_ast::*;
use rustc_ast_pretty::pprust;
use rustc_attr_parsing::{AttributeParser, OmitDoc};
use rustc_expand::expand::AstFragment;
use rustc_hir as hir;
use rustc_hir::def::{CtorKind, CtorOf, DefKind};
@ -132,8 +133,19 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {
ItemKind::Fn(..) | ItemKind::Delegation(..) => DefKind::Fn,
ItemKind::MacroDef(def) => {
let edition = i.span.edition();
// FIXME(jdonszelmann) make one of these in the resolver?
// FIXME(jdonszelmann) don't care about tools here maybe? Just parse what we can.
// Does that prevents errors from happening? maybe
let parser = AttributeParser::new(
&self.resolver.tcx.sess,
self.resolver.tcx.features(),
Vec::new(),
);
let attrs = parser.parse_attribute_list(&i.attrs, i.span, OmitDoc::Skip);
let macro_data =
self.resolver.compile_macro(def, i.ident, &i.attrs, i.span, i.id, edition);
self.resolver.compile_macro(def, i.ident, &attrs, i.span, i.id, edition);
let macro_kind = macro_data.ext.macro_kind();
opt_macro_data = Some(macro_data);
DefKind::Macro(macro_kind)

View file

@ -5,7 +5,6 @@ use std::cell::Cell;
use std::mem;
use std::sync::Arc;
use rustc_ast::attr::AttributeExt;
use rustc_ast::expand::StrippedCfgItem;
use rustc_ast::{self as ast, Crate, NodeId, attr};
use rustc_ast_pretty::pprust;
@ -1112,7 +1111,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
&mut self,
macro_def: &ast::MacroDef,
ident: Ident,
attrs: &[impl AttributeExt],
attrs: &[rustc_hir::Attribute],
span: Span,
node_id: NodeId,
edition: Edition,