Module attributes

Module attributes 

Source
Expand description

All the individual attribute parsers for each of rustc’s built-in attributes. This module defines traits for attribute parsers, little state machines that recognize and parse attributes out of a longer list of attributes. The main trait is called AttributeParser. You can find more docs about AttributeParsers on the trait itself. However, for many types of attributes, implementing AttributeParser is not necessary. It allows for a lot of flexibility you might not want.

Specifically, you might not care about managing the state of your AttributeParser state machine yourself. In this case you can choose to implement:

  • SingleAttributeParser: makes it easy to implement an attribute which should error if it appears more than once in a list of attributes
  • CombineAttributeParser: makes it easy to implement an attribute which should combine the contents of attributes, if an attribute appear multiple times in a list

Attributes should be added to crate::context::ATTRIBUTE_PARSERS to be parsed.

ModulesΒ§

allow_unstable πŸ”’
body πŸ”’
Attributes that can be found in function body.
cfg πŸ”’
cfg_old πŸ”’
codegen_attrs πŸ”’
confusables πŸ”’
crate_level πŸ”’
deprecation πŸ”’
dummy πŸ”’
inline πŸ”’
link_attrs πŸ”’
lint_helpers πŸ”’
loop_match πŸ”’
macro_attrs πŸ”’
must_use πŸ”’
no_implicit_prelude πŸ”’
non_exhaustive πŸ”’
path πŸ”’
prelude πŸ”’
All the parsers require roughly the same imports, so this prelude has most of the often-needed ones.
proc_macro_attrs πŸ”’
prototype πŸ”’
Attributes that are only used on function prototypes.
repr πŸ”’
rustc_internal πŸ”’
semantics πŸ”’
stability πŸ”’
test_attrs πŸ”’
traits πŸ”’
transparency πŸ”’
util πŸ”’

StructsΒ§

Combine πŸ”’
Use in combination with CombineAttributeParser. Combine<T: CombineAttributeParser> implements AttributeParser.
Single πŸ”’
Use in combination with SingleAttributeParser. Single<T: SingleAttributeParser> implements AttributeParser.
WithoutArgs πŸ”’

EnumsΒ§

AttributeOrder πŸ”’
OnDuplicate πŸ”’

TraitsΒ§

AttributeParser πŸ”’
An AttributeParser is a type which searches for syntactic attributes.
CombineAttributeParser πŸ”’
Alternative to AttributeParser that automatically handles state management. If multiple attributes appear on an element, combines the values of each into a ThinVec. Combine<T> where T: CombineAttributeParser implements AttributeParser.
NoArgsAttributeParser πŸ”’
An even simpler version of SingleAttributeParser: now automatically check that there are no arguments provided to the attribute.
SingleAttributeParser πŸ”’
Alternative to AttributeParser that automatically handles state management. A slightly simpler and more restricted way to convert attributes. Assumes that an attribute can only appear a single time on an item, and errors when it sees more.

Type AliasesΒ§

AcceptFn πŸ”’
AcceptMapping πŸ”’
ConvertFn πŸ”’