Lines Matching full:attribute

22     /// An attribute, like `#[repr(transparent)]`.
44 /// The `style` field of type `AttrStyle` distinguishes whether an attribute
47 /// Every attribute has a `path` that indicates the intended interpretation
48 /// of the rest of the attribute's contents. The path and the optional
50 /// attribute in three possible varieties:
53 /// path, for example the `#[test]` attribute.
82 /// # Parsing from tokens to Attribute
87 /// [`Attribute::parse_outer`] or [`Attribute::parse_inner`] depending on
95 /// use syn::{Attribute, Ident, Result, Token};
103 /// attrs: Vec<Attribute>,
112 /// attrs: input.call(Attribute::parse_outer)?,
123 /// # Parsing from Attribute to structured arguments
127 /// `Meta::List` variety of attribute are held in an arbitrary `tokens:
128 /// TokenStream`. Macros are expected to check the `path` of the attribute,
131 /// attribute. Use [`parse_args()`] to parse those tokens into the expected
134 /// [`parse_args()`]: Attribute::parse_args
142 /// expanded into an attribute of the form `#[doc = r"comment"]`.
175 pub struct Attribute {
183 impl Attribute { impl
184 /// Returns the path that identifies the interpretation of this attribute.
192 /// Parse the arguments to the attribute as a syntax tree.
210 /// use syn::{parse_quote, Attribute, Expr};
212 /// let attr: Attribute = parse_quote! {
228 /// Parse the arguments to the attribute using the given parser.
233 /// use syn::{parse_quote, Attribute};
235 /// let attr: Attribute = parse_quote! {
239 /// let bwom = attr.parse_args_with(Attribute::parse_outer)?;
241 /// // Attribute does not have a Parse impl, so we couldn't directly do:
242 /// // let bwom: Attribute = attr.parse_args()?;
253 "expected attribute arguments in parentheses: {}[{}(...)]", in parse_args_with()
270 /// Parse the arguments to the attribute, expecting it to follow the
273 /// The [*Meta Item Attribute Syntax*][syntax] section in the Rust reference
276 /// need to parse arbitrarily goofy attribute syntax.
278 /// [syntax]: https://doc.rust-lang.org/reference/attributes.html#meta-item-attribute-syntax
282 /// We'll parse a struct, and then parse some of Rust's `#[repr]` attribute
405 /// [*Parsing from tokens to Attribute*](#parsing-from-tokens-to-attribute).
421 /// [*Parsing from tokens to Attribute*](#parsing-from-tokens-to-attribute).
454 /// Content of a compile-time structured attribute.
478 /// A structured list within an attribute, like `derive(Copy, Clone)`.
481 /// A name-value pair within an attribute, like `feature = "nightly"`.
487 /// A structured list within an attribute, like `derive(Copy, Clone)`.
497 /// A name-value pair within an attribute, like `feature = "nightly"`.
528 Err(Error::new(error_span, "unexpected token in attribute")) in require_path_only()
541 "expected attribute arguments in parentheses: `{}(...)`", in require_list()
559 "expected a value for this attribute: `{} = ...`", in require_name_value()
569 /// See [`Attribute::parse_args`].
576 /// See [`Attribute::parse_args_with`].
584 /// See [`Attribute::parse_nested_meta`].
597 type Ret: Iterator<Item = &'a Attribute>;
605 impl<'a> FilterAttrs<'a> for &'a [Attribute] { implementation
606 type Ret = iter::Filter<slice::Iter<'a, Attribute>, fn(&&Attribute) -> bool>;
609 fn is_outer(attr: &&Attribute) -> bool { in outer()
620 fn is_inner(attr: &&Attribute) -> bool { in inner()
650 use crate::attr::{AttrStyle, Attribute, Meta, MetaList, MetaNameValue};
661 pub(crate) fn parse_inner(input: ParseStream, attrs: &mut Vec<Attribute>) -> Result<()> { in parse_inner()
668 pub(crate) fn single_parse_inner(input: ParseStream) -> Result<Attribute> { in single_parse_inner() argument
670 Ok(Attribute { in single_parse_inner()
678 pub(crate) fn single_parse_outer(input: ParseStream) -> Result<Attribute> { in single_parse_outer() argument
680 Ok(Attribute { in single_parse_outer()
713 // only the `unsafe` keyword is accepted as an attribute's outermost path.
753 return Err(input.error("unexpected attribute inside of attribute")); in parse_meta_name_value_after_path()
792 use crate::attr::{AttrStyle, Attribute, Meta, MetaList, MetaNameValue};
799 impl ToTokens for Attribute { implementation