pub(crate) trait CombineAttributeParser: 'static {
type Item;
const PATH: &[Symbol];
const CONVERT: fn(ThinVec<Self::Item>, Span) -> AttributeKind;
const STABILITY: AttributeStability;
const ALLOWED_TARGETS: AllowedTargets<'_>;
const TEMPLATE: AttributeTemplate;
const SAFETY: AttributeSafety = AttributeSafety::Normal;
// Required method
fn extend(
cx: &mut AcceptContext<'_, '_>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item>;
// Provided method
fn finalize_check(_cx: &FinalizeContext<'_, '_>, _attr_span: Span) { ... }
}Expand description
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.
CombineAttributeParser can only convert a single kind of attribute, and cannot combine multiple
attributes together like is necessary for #[stable()] and #[unstable()] for example.
Required Associated Constants§
const PATH: &[Symbol]
Sourceconst CONVERT: fn(ThinVec<Self::Item>, Span) -> AttributeKind
const CONVERT: fn(ThinVec<Self::Item>, Span) -> AttributeKind
A function that converts individual items (of type Item) into the final attribute.
For example, individual representations from #[repr(...)] attributes into an AttributeKind::Repr(x),
where x is a vec of these individual reprs.
const STABILITY: AttributeStability
const ALLOWED_TARGETS: AllowedTargets<'_>
Sourceconst TEMPLATE: AttributeTemplate
const TEMPLATE: AttributeTemplate
The template this attribute parser should implement. Used for diagnostics.
Provided Associated Constants§
const SAFETY: AttributeSafety = AttributeSafety::Normal
Required Associated Types§
Required Methods§
Sourcefn extend(
cx: &mut AcceptContext<'_, '_>,
args: &ArgParser,
) -> impl IntoIterator<Item = Self::Item>
fn extend( cx: &mut AcceptContext<'_, '_>, args: &ArgParser, ) -> impl IntoIterator<Item = Self::Item>
Converts a single syntactical attribute to a number of elements of the semantic attribute, or AttributeKind
Provided Methods§
Sourcefn finalize_check(_cx: &FinalizeContext<'_, '_>, _attr_span: Span)
fn finalize_check(_cx: &FinalizeContext<'_, '_>, _attr_span: Span)
Optional cross-attribute validation, run once during finalization after all
attributes on the item have been parsed. Has access to the sibling attributes via
FinalizeContext::all_attrs, so it can reject incompatible combinations.
attr_span is the span of the first attribute that was encountered.
Defaults to a no-op.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".