pub(crate) trait SingleAttributeParser<S: Stage>: 'static {
const PATH: &[Symbol];
const ATTRIBUTE_ORDER: AttributeOrder;
const ON_DUPLICATE: OnDuplicate<S>;
const TEMPLATE: AttributeTemplate;
// Required method
fn convert(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser<'_>,
) -> Option<AttributeKind>;
}
Expand description
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.
Single<T> where T: SingleAttributeParser
implements AttributeParser
.
SingleAttributeParser
can only convert attributes one-to-one, and cannot combine multiple
attributes together like is necessary for #[stable()]
and #[unstable()]
for example.
Required Associated Constants§
Sourceconst PATH: &[Symbol]
const PATH: &[Symbol]
The single path of the attribute this parser accepts.
If you need the parser to accept more than one path, use AttributeParser
instead
Sourceconst ATTRIBUTE_ORDER: AttributeOrder
const ATTRIBUTE_ORDER: AttributeOrder
Configures the precedence of attributes with the same PATH
on a syntax node.
Sourceconst ON_DUPLICATE: OnDuplicate<S>
const ON_DUPLICATE: OnDuplicate<S>
Configures what to do when when the same attribute is applied more than once on the same syntax node.
ATTRIBUTE_ORDER
specified which one is assumed to be correct,
and this specified whether to, for example, warn or error on the other one.
Sourceconst TEMPLATE: AttributeTemplate
const TEMPLATE: AttributeTemplate
The template this attribute parser should implement. Used for diagnostics.
Required Methods§
Sourcefn convert(
cx: &mut AcceptContext<'_, '_, S>,
args: &ArgParser<'_>,
) -> Option<AttributeKind>
fn convert( cx: &mut AcceptContext<'_, '_, S>, args: &ArgParser<'_>, ) -> Option<AttributeKind>
Converts a single syntactical attribute to a single semantic attribute, or AttributeKind
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.