diff options
| author | Jana Dönszelmann <jana@donsz.nl> | 2025-02-09 22:49:33 +0100 |
|---|---|---|
| committer | Jana Dönszelmann <jana@donsz.nl> | 2025-02-24 14:31:17 +0100 |
| commit | 7e0f5b50168c63bd1879067c043559ef0f01671e (patch) | |
| tree | b2f1b1f68ef89985faec8ae287731613e4b520c4 /compiler/rustc_resolve/src | |
| parent | dbd3b7928e91758296a0f6093d72f90214888133 (diff) | |
| download | rust-7e0f5b50168c63bd1879067c043559ef0f01671e.tar.gz rust-7e0f5b50168c63bd1879067c043559ef0f01671e.zip | |
Introduce new-style attribute parsers for several attributes
note: compiler compiles but librustdoc and clippy don't
Diffstat (limited to 'compiler/rustc_resolve/src')
| -rw-r--r-- | compiler/rustc_resolve/src/def_collector.rs | 14 | ||||
| -rw-r--r-- | compiler/rustc_resolve/src/macros.rs | 3 |
2 files changed, 14 insertions, 3 deletions
diff --git a/compiler/rustc_resolve/src/def_collector.rs b/compiler/rustc_resolve/src/def_collector.rs index 5eb8e420fa4..b050aabe225 100644 --- a/compiler/rustc_resolve/src/def_collector.rs +++ b/compiler/rustc_resolve/src/def_collector.rs @@ -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) diff --git a/compiler/rustc_resolve/src/macros.rs b/compiler/rustc_resolve/src/macros.rs index a70def2f6c9..984dfff3ea5 100644 --- a/compiler/rustc_resolve/src/macros.rs +++ b/compiler/rustc_resolve/src/macros.rs @@ -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, |
