pub enum Attribute {
Parsed(AttributeKind),
Tool(Box<AttrItem>),
DeriveHelper(Box<AttrItem>),
}Expand description
A high level representation of an attribute.
Not to be confused with ast::Attribute, which represents the syntax-level form of
an attribute.
Variants§
Parsed(AttributeKind)
A parsed built-in attribute.
Parsed attributes don’t generally have a span associated with them. This is because
multiple syntax-level attributes can be represented into a single semantic attribute. For
example, an item can have multiple repr attributes on it, which will coalesce into a
single AttributeKind::Repr, and the stable, unstable, and
rustc_allowed_through_unstable_modules all combine into a single
AttributeKind::Stability attribute. Most Attribute variants do have a Span field,
though, mostly for the purpose of generating diagnostics later in the compilation process.
Tool(Box<AttrItem>)
A tool attribute.
Tool attributes, with the exception of diagnostic attributes, are not converted into a parsed form.
DeriveHelper(Box<AttrItem>)
A derive helper attribute.
Derive helper attributes serve no use beyond macro expansion, but they are useful to
consumers of rustdoc-json, so we keep them around. See
https://github.com/rust-lang/rust/issues/157107 for context.
Implementations§
Source§impl Attribute
impl Attribute
pub fn value_lit(&self) -> Option<&MetaItemLit>
pub fn is_prefix_attr_for_suggestions(&self) -> bool
Trait Implementations§
Source§impl AttributeExt for Attribute
impl AttributeExt for Attribute
Source§fn name(&self) -> Option<Symbol>
fn name(&self) -> Option<Symbol>
For a single-segment attribute, returns its name; otherwise, returns None.
Source§fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>
fn meta_item_list(&self) -> Option<ThinVec<MetaItemInner>>
#[attr(meta item list)]Source§fn value_str(&self) -> Option<Symbol>
fn value_str(&self) -> Option<Symbol>
#[attr = value]Source§fn value_span(&self) -> Option<Span>
fn value_span(&self) -> Option<Span>
#[attr = value]Source§fn path_matches(&self, name: &[Symbol]) -> bool
fn path_matches(&self, name: &[Symbol]) -> bool
Source§fn is_doc_comment(&self) -> Option<Span>
fn is_doc_comment(&self) -> Option<Span>
true if it is a sugared doc comment (/// or //! for example).
So #[doc = "doc"] (which is a doc comment) and #[doc(...)] (which is not
a doc comment) will return false.fn path_span(&self) -> Option<Span>
Source§fn doc_str(&self) -> Option<Symbol>
fn doc_str(&self) -> Option<Symbol>
Source§fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind, Span)>
fn doc_str_and_fragment_kind(&self) -> Option<(Symbol, DocFragmentKind, Span)>
Source§fn doc_resolution_scope(&self) -> Option<AttrStyle>
fn doc_resolution_scope(&self) -> Option<AttrStyle>
Source§fn is_proc_macro_attr(&self) -> bool
fn is_proc_macro_attr(&self) -> bool
proc_macro, proc_macro_attribute or proc_macro_derive.Source§fn is_doc_keyword_or_attribute(&self) -> bool
fn is_doc_keyword_or_attribute(&self) -> bool
true is this attribute contains doc(keyword) or doc(attribute).Source§fn is_rustc_doc_primitive(&self) -> bool
fn is_rustc_doc_primitive(&self) -> bool
true if this is a #[rustc_doc_primitive] attribute.Source§fn has_name(&self, name: Symbol) -> bool
fn has_name(&self, name: Symbol) -> bool
Source§fn has_any_name(&self, names: &[Symbol]) -> bool
fn has_any_name(&self, names: &[Symbol]) -> bool
fn path(&self) -> SmallVec<[Symbol; 1]>
Source§impl<__D: SpanDecoder> Decodable<__D> for Attribute
impl<__D: SpanDecoder> Decodable<__D> for Attribute
Source§impl<__E: SpanEncoder> Encodable<__E> for Attribute
impl<__E: SpanEncoder> Encodable<__E> for Attribute
Source§impl StableHash for Attribute
impl StableHash for Attribute
fn stable_hash<__Hcx: StableHashCtxt>( &self, __hcx: &mut __Hcx, __hasher: &mut StableHasher, )
Auto Trait Implementations§
impl DynSend for Attribute
impl DynSync for Attribute
impl Freeze for Attribute
impl RefUnwindSafe for Attribute
impl Send for Attribute
impl Sync for Attribute
impl Unpin for Attribute
impl UnsafeUnpin for Attribute
impl UnwindSafe for Attribute
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 40 bytes
Size for each variant:
Parsed: 40 bytesTool: 16 bytesDeriveHelper: 16 bytes