rustc_ast::ast_traits

Trait 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))

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so 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