use tracing::debug;
+// Public for rustfmt usage
#[derive(Debug)]
-pub(super) enum InnerAttrPolicy<'a> {
+pub enum InnerAttrPolicy<'a> {
Permitted,
Forbidden { reason: &'a str, saw_doc_comment: bool, prev_attr_sp: Option<Span> },
}
/// Matches `attribute = # ! [ meta_item ]`.
/// `inner_parse_policy` prescribes how to handle inner attributes.
- fn parse_attribute(
+ // Public for rustfmt usage.
+ pub fn parse_attribute(
&mut self,
inner_parse_policy: InnerAttrPolicy<'_>,
) -> PResult<'a, ast::Attribute> {
}
pub fn maybe_needs_tokens(attrs: &[ast::Attribute]) -> bool {
+ // One of the attributes may either itself be a macro, or apply derive macros (`derive`),
+ // or expand to macro attributes (`cfg_attr`).
attrs.iter().any(|attr| {
- if let Some(ident) = attr.ident() {
+ attr.ident().map_or(true, |ident| {
ident.name == sym::derive
- // This might apply a custom attribute/derive
- || ident.name == sym::cfg_attr
- || !rustc_feature::is_builtin_attr_name(ident.name)
- } else {
- true
- }
+ || ident.name == sym::cfg_attr
+ || !rustc_feature::is_builtin_attr_name(ident.name)
+ })
})
}