Trait rustc_ast::ast_traits::HasAttrs

source ·
pub trait HasAttrs {
    const SUPPORTS_CUSTOM_INNER_ATTRS: bool;

    // Required methods
    fn attrs(&self) -> &[Attribute];
    fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec));
}
Expand description

A trait for AST nodes having (or not having) attributes.

Required Associated Constants§

source

const SUPPORTS_CUSTOM_INNER_ATTRS: bool

This is true if this HasAttrs might support ‘custom’ (proc-macro) inner attributes. Attributes like #![cfg] and #![cfg_attr] are not considered ‘custom’ attributes.

If this is false, then this HasAttrs definitely does not support ‘custom’ inner attributes, which enables some optimizations during token collection.

Required Methods§

source

fn attrs(&self) -> &[Attribute]

source

fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec))

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T: HasAttrs> HasAttrs for Option<T>

source§

const SUPPORTS_CUSTOM_INNER_ATTRS: bool = T::SUPPORTS_CUSTOM_INNER_ATTRS

source§

fn attrs(&self) -> &[Attribute]

source§

fn visit_attrs(&mut self, f: impl FnOnce(&mut AttrVec))

Implementors§

source§

impl HasAttrs for StmtKind

source§

impl HasAttrs for Arm

source§

impl HasAttrs for AttrItem

source§

impl HasAttrs for Attribute

source§

impl HasAttrs for Block

source§

impl HasAttrs for Crate

source§

impl HasAttrs for Expr

source§

impl HasAttrs for ExprField

source§

impl HasAttrs for FieldDef

source§

impl HasAttrs for GenericParam

source§

impl HasAttrs for Item

source§

impl HasAttrs for Param

source§

impl HasAttrs for Pat

source§

impl HasAttrs for PatField

source§

impl HasAttrs for Path

source§

impl HasAttrs for Stmt

source§

impl HasAttrs for Ty

source§

impl HasAttrs for Variant

source§

impl HasAttrs for Visibility

source§

impl HasAttrs for AssocItem

source§

impl HasAttrs for ForeignItem

source§

impl<T: AstDeref<Target: HasAttrs>> HasAttrs for T

source§

const SUPPORTS_CUSTOM_INNER_ATTRS: bool = <T::Target>::SUPPORTS_CUSTOM_INNER_ATTRS