Skip to content

Commit

Permalink
Make all attribute parsing examples actually run
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 16, 2023
1 parent 7c84b23 commit 2397e53
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
12 changes: 3 additions & 9 deletions src/attr.rs
Expand Up @@ -199,7 +199,6 @@ impl Attribute {
/// # Example
///
/// ```
/// # fn example() -> syn::Result<()> {
/// use syn::{parse_quote, Attribute, Expr};
///
/// let attr: Attribute = parse_quote! {
Expand All @@ -210,8 +209,7 @@ impl Attribute {
/// let precondition: Expr = attr.parse_args()?;
/// // ...
/// }
/// # Ok(())
/// # }
/// # anyhow::Ok(())
/// ```
#[cfg(feature = "parsing")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
Expand All @@ -224,7 +222,6 @@ impl Attribute {
/// # Example
///
/// ```
/// # fn example() -> syn::Result<()> {
/// use syn::{parse_quote, Attribute};
///
/// let attr: Attribute = parse_quote! {
Expand All @@ -235,8 +232,7 @@ impl Attribute {
///
/// // Attribute does not have a Parse impl, so we couldn't directly do:
/// // let bwom: Attribute = attr.parse_args()?;
/// # Ok(())
/// # }
/// # anyhow::Ok(())
/// ```
#[cfg(feature = "parsing")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
Expand Down Expand Up @@ -276,7 +272,6 @@ impl Attribute {
/// syntax.
///
/// ```
/// # fn example() -> syn::Result<()> {
/// use syn::{parenthesized, parse_quote, token, ItemStruct, LitInt};
///
/// let input: ItemStruct = parse_quote! {
Expand Down Expand Up @@ -331,8 +326,7 @@ impl Attribute {
/// })?;
/// }
/// }
/// # Ok(())
/// # }
/// # anyhow::Ok(())
/// ```
#[cfg(feature = "parsing")]
#[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
Expand Down
12 changes: 3 additions & 9 deletions src/meta.rs
Expand Up @@ -170,7 +170,6 @@ impl<'a> ParseNestedMeta<'a> {
/// # Example
///
/// ```
/// # fn example() -> syn::Result<()> {
/// use syn::{parse_quote, Attribute, LitStr};
///
/// let attr: Attribute = parse_quote! {
Expand All @@ -191,8 +190,7 @@ impl<'a> ParseNestedMeta<'a> {
/// }
/// })?;
/// }
/// # Ok(())
/// # }
/// # anyhow::Ok(())
/// ```
pub fn value(&self) -> Result<ParseStream<'a>> {
self.input.parse::<Token![=]>()?;
Expand All @@ -206,7 +204,6 @@ impl<'a> ParseNestedMeta<'a> {
/// # Example
///
/// ```
/// # fn example() -> syn::Result<()> {
/// use syn::{parse_quote, Attribute};
///
/// let attr: Attribute = parse_quote! {
Expand All @@ -231,8 +228,7 @@ impl<'a> ParseNestedMeta<'a> {
/// }
/// })?;
/// }
/// # Ok(())
/// # }
/// # anyhow::Ok(())
/// ```
///
/// # Counterexample
Expand All @@ -244,7 +240,6 @@ impl<'a> ParseNestedMeta<'a> {
/// `parse_nested_meta` is not what you want.
///
/// ```
/// # fn example() -> syn::Result<()> {
/// use syn::{parenthesized, parse_quote, Attribute, LitInt};
///
/// let attr: Attribute = parse_quote! {
Expand All @@ -264,8 +259,7 @@ impl<'a> ParseNestedMeta<'a> {
/// }
/// })?;
/// }
/// # Ok(())
/// # }
/// # anyhow::Ok(())
/// ```
pub fn parse_nested_meta(
&self,
Expand Down

0 comments on commit 2397e53

Please sign in to comment.