mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Remove NonMacroAttr.mark_used
This commit is contained in:
parent
af46699f81
commit
17aef21b30
@ -654,10 +654,7 @@ pub enum SyntaxExtensionKind {
|
||||
/// A trivial attribute "macro" that does nothing,
|
||||
/// only keeps the attribute and marks it as inert,
|
||||
/// thus making it ineligible for further expansion.
|
||||
NonMacroAttr {
|
||||
/// Suppresses the `unused_attributes` lint for this attribute.
|
||||
mark_used: bool,
|
||||
},
|
||||
NonMacroAttr,
|
||||
|
||||
/// A token-based derive macro.
|
||||
Derive(
|
||||
@ -706,7 +703,7 @@ impl SyntaxExtension {
|
||||
SyntaxExtensionKind::Bang(..) | SyntaxExtensionKind::LegacyBang(..) => MacroKind::Bang,
|
||||
SyntaxExtensionKind::Attr(..)
|
||||
| SyntaxExtensionKind::LegacyAttr(..)
|
||||
| SyntaxExtensionKind::NonMacroAttr { .. } => MacroKind::Attr,
|
||||
| SyntaxExtensionKind::NonMacroAttr => MacroKind::Attr,
|
||||
SyntaxExtensionKind::Derive(..) | SyntaxExtensionKind::LegacyDerive(..) => {
|
||||
MacroKind::Derive
|
||||
}
|
||||
@ -812,8 +809,8 @@ impl SyntaxExtension {
|
||||
SyntaxExtension::default(SyntaxExtensionKind::Derive(Box::new(expander)), edition)
|
||||
}
|
||||
|
||||
pub fn non_macro_attr(mark_used: bool, edition: Edition) -> SyntaxExtension {
|
||||
SyntaxExtension::default(SyntaxExtensionKind::NonMacroAttr { mark_used }, edition)
|
||||
pub fn non_macro_attr(edition: Edition) -> SyntaxExtension {
|
||||
SyntaxExtension::default(SyntaxExtensionKind::NonMacroAttr, edition)
|
||||
}
|
||||
|
||||
pub fn expn_data(
|
||||
|
@ -753,7 +753,7 @@ impl<'a, 'b> MacroExpander<'a, 'b> {
|
||||
}
|
||||
}
|
||||
}
|
||||
SyntaxExtensionKind::NonMacroAttr { mark_used: _ } => {
|
||||
SyntaxExtensionKind::NonMacroAttr => {
|
||||
self.cx.expanded_inert_attrs.mark(&attr);
|
||||
item.visit_attrs(|attrs| attrs.insert(pos, attr));
|
||||
fragment_kind.expect_from_annotatables(iter::once(item))
|
||||
|
@ -195,7 +195,7 @@ impl<'a> Resolver<'a> {
|
||||
crate fn get_macro(&mut self, res: Res) -> Option<Lrc<SyntaxExtension>> {
|
||||
match res {
|
||||
Res::Def(DefKind::Macro(..), def_id) => Some(self.get_macro_by_def_id(def_id)),
|
||||
Res::NonMacroAttr(attr_kind) => Some(self.non_macro_attr(attr_kind.is_used())),
|
||||
Res::NonMacroAttr(_) => Some(self.non_macro_attr.clone()),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
@ -968,7 +968,7 @@ pub struct Resolver<'a> {
|
||||
macro_map: FxHashMap<DefId, Lrc<SyntaxExtension>>,
|
||||
dummy_ext_bang: Lrc<SyntaxExtension>,
|
||||
dummy_ext_derive: Lrc<SyntaxExtension>,
|
||||
non_macro_attrs: [Lrc<SyntaxExtension>; 2],
|
||||
non_macro_attr: Lrc<SyntaxExtension>,
|
||||
local_macro_def_scopes: FxHashMap<LocalDefId, Module<'a>>,
|
||||
ast_transform_scopes: FxHashMap<LocalExpnId, Module<'a>>,
|
||||
unused_macros: FxHashMap<LocalDefId, (NodeId, Span)>,
|
||||
@ -1293,8 +1293,6 @@ impl<'a> Resolver<'a> {
|
||||
macros::registered_attrs_and_tools(session, &krate.attrs);
|
||||
|
||||
let features = session.features_untracked();
|
||||
let non_macro_attr =
|
||||
|mark_used| Lrc::new(SyntaxExtension::non_macro_attr(mark_used, session.edition()));
|
||||
|
||||
let mut resolver = Resolver {
|
||||
session,
|
||||
@ -1361,7 +1359,7 @@ impl<'a> Resolver<'a> {
|
||||
macro_map: FxHashMap::default(),
|
||||
dummy_ext_bang: Lrc::new(SyntaxExtension::dummy_bang(session.edition())),
|
||||
dummy_ext_derive: Lrc::new(SyntaxExtension::dummy_derive(session.edition())),
|
||||
non_macro_attrs: [non_macro_attr(false), non_macro_attr(true)],
|
||||
non_macro_attr: Lrc::new(SyntaxExtension::non_macro_attr(session.edition())),
|
||||
invocation_parent_scopes: Default::default(),
|
||||
output_macro_rules_scopes: Default::default(),
|
||||
helper_attrs: Default::default(),
|
||||
@ -1476,15 +1474,11 @@ impl<'a> Resolver<'a> {
|
||||
self.crate_loader.cstore()
|
||||
}
|
||||
|
||||
fn non_macro_attr(&self, mark_used: bool) -> Lrc<SyntaxExtension> {
|
||||
self.non_macro_attrs[mark_used as usize].clone()
|
||||
}
|
||||
|
||||
fn dummy_ext(&self, macro_kind: MacroKind) -> Lrc<SyntaxExtension> {
|
||||
match macro_kind {
|
||||
MacroKind::Bang => self.dummy_ext_bang.clone(),
|
||||
MacroKind::Derive => self.dummy_ext_derive.clone(),
|
||||
MacroKind::Attr => self.non_macro_attr(true),
|
||||
MacroKind::Attr => self.non_macro_attr.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user