diff --git a/Cargo.toml b/Cargo.toml
index 7a53a63bbc..0fbb45eda2 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -64,6 +64,7 @@ required-features = ["full", "parsing"]
[package.metadata.docs.rs]
all-features = true
targets = ["x86_64-unknown-linux-gnu"]
+rustdoc-args = ["--cfg", "docsrs"]
[package.metadata.playground]
features = ["full", "visit", "visit-mut", "fold", "extra-traits"]
diff --git a/src/attr.rs b/src/attr.rs
index 2a51c3801b..80d1c21a7d 100644
--- a/src/attr.rs
+++ b/src/attr.rs
@@ -17,11 +17,6 @@ use std::hash::{Hash, Hasher};
ast_struct! {
/// An attribute like `#[repr(transparent)]`.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
- ///
- ///
/// # Syntax
///
/// Rust has six types of attributes.
@@ -148,6 +143,7 @@ ast_struct! {
/// };
/// assert_eq!(doc, attr);
/// ```
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Attribute #manual_extra_traits {
pub pound_token: Token![#],
pub style: AttrStyle,
@@ -188,10 +184,8 @@ impl Hash for Attribute {
impl Attribute {
/// Parses the content of the attribute, consisting of the path and tokens,
/// as a [`Meta`] if possible.
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_meta(&self) -> Result {
fn clone_ident_segment(segment: &PathSegment) -> PathSegment {
PathSegment {
@@ -235,19 +229,15 @@ impl Attribute {
/// #[my_attr(value < 5)]
/// ^^^^^^^^^ what gets parsed
/// ```
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_args(&self) -> Result {
self.parse_args_with(T::parse)
}
/// Parse the arguments to the attribute using the given parser.
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_args_with(&self, parser: F) -> Result {
let parser = |input: ParseStream| {
let args = enter_args(self, input)?;
@@ -257,10 +247,8 @@ impl Attribute {
}
/// Parses zero or more outer attributes from the stream.
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_outer(input: ParseStream) -> Result> {
let mut attrs = Vec::new();
while input.peek(Token![#]) && !input.peek(token::Group) {
@@ -270,10 +258,8 @@ impl Attribute {
}
/// Parses zero or more inner attributes from the stream.
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_inner(input: ParseStream) -> Result> {
let mut attrs = Vec::new();
while input.peek(Token![#]) && input.peek2(Token![!]) && !input.peek(token::Group) {
@@ -339,9 +325,6 @@ ast_enum! {
/// Distinguishes between attributes that decorate an item and attributes
/// that are contained within an item.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
/// # Outer attributes
///
/// - `#[repr(transparent)]`
@@ -354,6 +337,7 @@ ast_enum! {
/// - `//! # Example`
/// - `/*! Please file an issue */`
#[cfg_attr(feature = "clone-impls", derive(Copy))]
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum AttrStyle {
Outer,
Inner(Token![!]),
@@ -363,9 +347,6 @@ ast_enum! {
ast_enum_of_structs! {
/// Content of a compile-time structured attribute.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
/// ## Path
///
/// A meta path is like the `test` in `#[test]`.
@@ -387,6 +368,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum Meta {
Path(Path),
@@ -400,9 +382,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A structured list within an attribute, like `derive(Copy, Clone)`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct MetaList {
pub path: Path,
pub paren_token: token::Paren,
@@ -412,9 +392,7 @@ ast_struct! {
ast_struct! {
/// A name-value pair within an attribute, like `feature = "nightly"`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct MetaNameValue {
pub path: Path,
pub eq_token: Token![=],
@@ -438,9 +416,7 @@ impl Meta {
ast_enum_of_structs! {
/// Element of a compile-time attribute list.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum NestedMeta {
/// A structured meta item, like the `Copy` in `#[derive(Copy)]` which
/// would be a nested `Meta::Path`.
diff --git a/src/buffer.rs b/src/buffer.rs
index 73255d6e9e..0005781d19 100644
--- a/src/buffer.rs
+++ b/src/buffer.rs
@@ -1,7 +1,7 @@
//! A stably addressed token buffer supporting efficient traversal based on a
//! cheaply copyable cursor.
-//!
-//! *This module is available only if Syn is built with the `"parsing"` feature.*
+
+#![cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
// This module is heavily commented as it contains most of the unsafe code in
// Syn, and caution should be used when editing it. The public-facing interface
@@ -35,8 +35,7 @@ enum Entry {
/// A buffer that can be efficiently traversed multiple times, unlike
/// `TokenStream` which requires a deep copy in order to traverse more than
/// once.
-///
-/// *This type is available only if Syn is built with the `"parsing"` feature.*
+#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub struct TokenBuffer {
// NOTE: Do not derive clone on this - there are raw pointers inside which
// will be messed up. Moving the `TokenBuffer` itself is safe as the actual
@@ -97,13 +96,11 @@ impl TokenBuffer {
/// Creates a `TokenBuffer` containing all the tokens from the input
/// `TokenStream`.
- ///
- /// *This method is available only if Syn is built with both the `"parsing"` and
- /// `"proc-macro"` features.*
#[cfg(all(
not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
feature = "proc-macro"
))]
+ #[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "proc-macro"))))]
pub fn new(stream: pm::TokenStream) -> TokenBuffer {
Self::new2(stream.into())
}
@@ -132,9 +129,8 @@ impl TokenBuffer {
///
/// Two cursors are equal if they have the same location in the same input
/// stream, and have the same scope.
-///
-/// *This type is available only if Syn is built with the `"parsing"` feature.*
#[derive(Copy, Clone, Eq, PartialEq)]
+#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub struct Cursor<'a> {
// The current entry which the `Cursor` is pointing at.
ptr: *const Entry,
diff --git a/src/data.rs b/src/data.rs
index b217b8ca6f..3030c819fd 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -3,9 +3,7 @@ use crate::punctuated::Punctuated;
ast_struct! {
/// An enum variant.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Variant {
/// Attributes tagged on the variant.
pub attrs: Vec,
@@ -24,9 +22,6 @@ ast_struct! {
ast_enum_of_structs! {
/// Data stored within an enum variant or struct.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -35,6 +30,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum Fields {
/// Named fields of a struct or struct variant such as `Point { x: f64,
/// y: f64 }`.
@@ -51,9 +47,7 @@ ast_enum_of_structs! {
ast_struct! {
/// Named fields of a struct or struct variant such as `Point { x: f64,
/// y: f64 }`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct FieldsNamed {
pub brace_token: token::Brace,
pub named: Punctuated,
@@ -62,9 +56,7 @@ ast_struct! {
ast_struct! {
/// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct FieldsUnnamed {
pub paren_token: token::Paren,
pub unnamed: Punctuated,
@@ -146,9 +138,7 @@ impl<'a> IntoIterator for &'a mut Fields {
ast_struct! {
/// A field of a struct or enum variant.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Field {
/// Attributes tagged on the field.
pub attrs: Vec,
@@ -172,9 +162,6 @@ ast_enum_of_structs! {
/// The visibility level of an item: inherited or `pub` or
/// `pub(restricted)`.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -183,6 +170,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum Visibility {
/// A public visibility level: `pub`.
Public(VisPublic),
@@ -201,9 +189,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A public visibility level: `pub`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct VisPublic {
pub pub_token: Token![pub],
}
@@ -211,9 +197,7 @@ ast_struct! {
ast_struct! {
/// A crate-level visibility: `crate`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct VisCrate {
pub crate_token: Token![crate],
}
@@ -222,9 +206,7 @@ ast_struct! {
ast_struct! {
/// A visibility level restricted to some path: `pub(self)` or
/// `pub(super)` or `pub(crate)` or `pub(in some::module)`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct VisRestricted {
pub pub_token: Token![pub],
pub paren_token: token::Paren,
diff --git a/src/derive.rs b/src/derive.rs
index 3fa9d89a93..c39713243d 100644
--- a/src/derive.rs
+++ b/src/derive.rs
@@ -3,8 +3,7 @@ use crate::punctuated::Punctuated;
ast_struct! {
/// Data structure sent to a `proc_macro_derive` macro.
- ///
- /// *This type is available only if Syn is built with the `"derive"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub struct DeriveInput {
/// Attributes tagged on the whole struct or enum.
pub attrs: Vec,
@@ -26,8 +25,6 @@ ast_struct! {
ast_enum_of_structs! {
/// The storage of a struct, enum or union data structure.
///
- /// *This type is available only if Syn is built with the `"derive"` feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -36,6 +33,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub enum Data {
/// A struct input to a `proc_macro_derive` macro.
Struct(DataStruct),
@@ -52,9 +50,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A struct input to a `proc_macro_derive` macro.
- ///
- /// *This type is available only if Syn is built with the `"derive"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub struct DataStruct {
pub struct_token: Token![struct],
pub fields: Fields,
@@ -64,9 +60,7 @@ ast_struct! {
ast_struct! {
/// An enum input to a `proc_macro_derive` macro.
- ///
- /// *This type is available only if Syn is built with the `"derive"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub struct DataEnum {
pub enum_token: Token![enum],
pub brace_token: token::Brace,
@@ -76,9 +70,7 @@ ast_struct! {
ast_struct! {
/// An untagged union input to a `proc_macro_derive` macro.
- ///
- /// *This type is available only if Syn is built with the `"derive"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "derive")))]
pub struct DataUnion {
pub union_token: Token![union],
pub fields: FieldsNamed,
diff --git a/src/expr.rs b/src/expr.rs
index ce87136e4c..41e591e598 100644
--- a/src/expr.rs
+++ b/src/expr.rs
@@ -14,9 +14,6 @@ use std::mem;
ast_enum_of_structs! {
/// A Rust expression.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature, but most of the variants are not available unless "full" is enabled.*
- ///
/// # Syntax tree enums
///
/// This type is a syntax tree enum. In Syn this and other syntax tree enums
@@ -86,6 +83,7 @@ ast_enum_of_structs! {
/// A sign that you may not be choosing the right variable names is if you
/// see names getting repeated in your code, like accessing
/// `receiver.receiver` or `pat.pat` or `cond.cond`.
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum Expr #manual_extra_traits {
/// A slice literal expression: `[a, b, c, d]`.
Array(ExprArray),
@@ -230,8 +228,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A slice literal expression: `[a, b, c, d]`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprArray #full {
pub attrs: Vec,
pub bracket_token: token::Bracket,
@@ -241,8 +238,7 @@ ast_struct! {
ast_struct! {
/// An assignment expression: `a = compute()`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprAssign #full {
pub attrs: Vec,
pub left: Box,
@@ -253,8 +249,7 @@ ast_struct! {
ast_struct! {
/// A compound assignment expression: `counter += 1`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprAssignOp #full {
pub attrs: Vec,
pub left: Box,
@@ -265,8 +260,7 @@ ast_struct! {
ast_struct! {
/// An async block: `async { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprAsync #full {
pub attrs: Vec,
pub async_token: Token![async],
@@ -277,8 +271,7 @@ ast_struct! {
ast_struct! {
/// An await expression: `fut.await`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprAwait #full {
pub attrs: Vec,
pub base: Box,
@@ -289,9 +282,7 @@ ast_struct! {
ast_struct! {
/// A binary operation: `a + b`, `a * b`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ExprBinary {
pub attrs: Vec,
pub left: Box,
@@ -302,8 +293,7 @@ ast_struct! {
ast_struct! {
/// A blocked scope: `{ ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprBlock #full {
pub attrs: Vec,
pub label: Option,
@@ -313,8 +303,7 @@ ast_struct! {
ast_struct! {
/// A box expression: `box f`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprBox #full {
pub attrs: Vec,
pub box_token: Token![box],
@@ -325,8 +314,7 @@ ast_struct! {
ast_struct! {
/// A `break`, with an optional label to break and an optional
/// expression.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprBreak #full {
pub attrs: Vec,
pub break_token: Token![break],
@@ -337,9 +325,7 @@ ast_struct! {
ast_struct! {
/// A function call expression: `invoke(a, b)`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ExprCall {
pub attrs: Vec,
pub func: Box,
@@ -350,9 +336,7 @@ ast_struct! {
ast_struct! {
/// A cast expression: `foo as f64`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ExprCast {
pub attrs: Vec,
pub expr: Box,
@@ -363,8 +347,7 @@ ast_struct! {
ast_struct! {
/// A closure expression: `|a, b| a + b`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprClosure #full {
pub attrs: Vec,
pub asyncness: Option,
@@ -380,8 +363,7 @@ ast_struct! {
ast_struct! {
/// A `continue`, with an optional label.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprContinue #full {
pub attrs: Vec,
pub continue_token: Token![continue],
@@ -392,8 +374,7 @@ ast_struct! {
ast_struct! {
/// Access of a named struct field (`obj.k`) or unnamed tuple struct
/// field (`obj.0`).
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprField {
pub attrs: Vec,
pub base: Box,
@@ -404,8 +385,7 @@ ast_struct! {
ast_struct! {
/// A for loop: `for pat in expr { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprForLoop #full {
pub attrs: Vec,
pub label: Option,
@@ -423,8 +403,7 @@ ast_struct! {
/// This variant is important for faithfully representing the precedence
/// of expressions and is related to `None`-delimited spans in a
/// `TokenStream`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprGroup #full {
pub attrs: Vec,
pub group_token: token::Group,
@@ -438,8 +417,7 @@ ast_struct! {
///
/// The `else` branch expression may only be an `If` or `Block`
/// expression, not any of the other types of expression.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprIf #full {
pub attrs: Vec,
pub if_token: Token![if],
@@ -451,9 +429,7 @@ ast_struct! {
ast_struct! {
/// A square bracketed indexing expression: `vector[2]`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ExprIndex {
pub attrs: Vec,
pub expr: Box,
@@ -464,8 +440,7 @@ ast_struct! {
ast_struct! {
/// A `let` guard: `let Some(x) = opt`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprLet #full {
pub attrs: Vec,
pub let_token: Token![let],
@@ -477,9 +452,7 @@ ast_struct! {
ast_struct! {
/// A literal in place of an expression: `1`, `"foo"`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ExprLit {
pub attrs: Vec,
pub lit: Lit,
@@ -488,8 +461,7 @@ ast_struct! {
ast_struct! {
/// Conditionless loop: `loop { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprLoop #full {
pub attrs: Vec,
pub label: Option,
@@ -500,8 +472,7 @@ ast_struct! {
ast_struct! {
/// A macro invocation expression: `format!("{}", q)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprMacro #full {
pub attrs: Vec,
pub mac: Macro,
@@ -510,8 +481,7 @@ ast_struct! {
ast_struct! {
/// A `match` expression: `match n { Some(n) => {}, None => {} }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprMatch #full {
pub attrs: Vec,
pub match_token: Token![match],
@@ -523,8 +493,7 @@ ast_struct! {
ast_struct! {
/// A method call expression: `x.foo::(a, b)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprMethodCall #full {
pub attrs: Vec,
pub receiver: Box,
@@ -538,8 +507,7 @@ ast_struct! {
ast_struct! {
/// A parenthesized expression: `(a + b)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprParen {
pub attrs: Vec,
pub paren_token: token::Paren,
@@ -552,9 +520,7 @@ ast_struct! {
/// parameters and a qualified self-type.
///
/// A plain identifier like `x` is a path of length 1.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ExprPath {
pub attrs: Vec,
pub qself: Option,
@@ -564,8 +530,7 @@ ast_struct! {
ast_struct! {
/// A range expression: `1..2`, `1..`, `..2`, `1..=2`, `..=2`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprRange #full {
pub attrs: Vec,
pub from: Option>,
@@ -576,8 +541,7 @@ ast_struct! {
ast_struct! {
/// A referencing operation: `&a` or `&mut a`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprReference #full {
pub attrs: Vec,
pub and_token: Token![&],
@@ -589,8 +553,7 @@ ast_struct! {
ast_struct! {
/// An array literal constructed from one repeated element: `[0u8; N]`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprRepeat #full {
pub attrs: Vec,
pub bracket_token: token::Bracket,
@@ -602,8 +565,7 @@ ast_struct! {
ast_struct! {
/// A `return`, with an optional value to be returned.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprReturn #full {
pub attrs: Vec,
pub return_token: Token![return],
@@ -616,8 +578,7 @@ ast_struct! {
///
/// The `rest` provides the value of the remaining fields as in `S { a:
/// 1, b: 1, ..rest }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprStruct #full {
pub attrs: Vec,
pub path: Path,
@@ -630,8 +591,7 @@ ast_struct! {
ast_struct! {
/// A try-expression: `expr?`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprTry #full {
pub attrs: Vec,
pub expr: Box,
@@ -641,8 +601,7 @@ ast_struct! {
ast_struct! {
/// A try block: `try { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprTryBlock #full {
pub attrs: Vec,
pub try_token: Token![try],
@@ -652,8 +611,7 @@ ast_struct! {
ast_struct! {
/// A tuple expression: `(a, b, c, d)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprTuple #full {
pub attrs: Vec,
pub paren_token: token::Paren,
@@ -663,8 +621,7 @@ ast_struct! {
ast_struct! {
/// A type ascription expression: `foo: f64`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprType #full {
pub attrs: Vec,
pub expr: Box,
@@ -675,9 +632,7 @@ ast_struct! {
ast_struct! {
/// A unary operation: `!x`, `*x`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ExprUnary {
pub attrs: Vec,
pub op: UnOp,
@@ -687,8 +642,7 @@ ast_struct! {
ast_struct! {
/// An unsafe block: `unsafe { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprUnsafe #full {
pub attrs: Vec,
pub unsafe_token: Token![unsafe],
@@ -698,8 +652,7 @@ ast_struct! {
ast_struct! {
/// A while loop: `while expr { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprWhile #full {
pub attrs: Vec,
pub label: Option,
@@ -711,8 +664,7 @@ ast_struct! {
ast_struct! {
/// A yield expression: `yield expr`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ExprYield #full {
pub attrs: Vec,
pub yield_token: Token![yield],
@@ -998,9 +950,7 @@ impl Expr {
ast_enum! {
/// A struct or tuple struct field accessed in a struct literal or field
/// expression.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
#[derive(Eq, PartialEq, Hash)]
pub enum Member #manual_extra_traits {
/// A named field like `self.x`.
@@ -1029,9 +979,7 @@ impl IdentFragment for Member {
ast_struct! {
/// The index of an unnamed tuple struct field.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Index #manual_extra_traits {
pub index: u32,
pub span: Span,
@@ -1085,8 +1033,7 @@ ast_struct! {
ast_struct! {
/// The `::<>` explicit type parameters passed to a method call:
/// `parse::()`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct MethodTurbofish {
pub colon2_token: Token![::],
pub lt_token: Token![<],
@@ -1098,8 +1045,7 @@ ast_struct! {
#[cfg(feature = "full")]
ast_enum! {
/// An individual generic argument to a method, like `T`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum GenericMethodArgument {
/// A type argument.
Type(Type),
@@ -1114,8 +1060,7 @@ ast_enum! {
#[cfg(feature = "full")]
ast_struct! {
/// A field-value pair in a struct literal.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct FieldValue {
/// Attributes tagged on the field.
pub attrs: Vec,
@@ -1135,8 +1080,7 @@ ast_struct! {
#[cfg(feature = "full")]
ast_struct! {
/// A lifetime labeling a `for`, `while`, or `loop`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct Label {
pub name: Lifetime,
pub colon_token: Token![:],
@@ -1162,8 +1106,7 @@ ast_struct! {
/// # false
/// # }
/// ```
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct Arm {
pub attrs: Vec,
pub pat: Pat,
@@ -1177,8 +1120,7 @@ ast_struct! {
#[cfg(feature = "full")]
ast_enum! {
/// Limit types of a range, inclusive or exclusive.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
#[cfg_attr(feature = "clone-impls", derive(Copy))]
pub enum RangeLimits {
/// Inclusive at the beginning, exclusive at the end.
diff --git a/src/ext.rs b/src/ext.rs
index b58baaafc3..71e6533d29 100644
--- a/src/ext.rs
+++ b/src/ext.rs
@@ -1,6 +1,6 @@
//! Extension traits to provide parsing methods on foreign types.
-//!
-//! *This module is available only if Syn is built with the `"parsing"` feature.*
+
+#![cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
use proc_macro2::Ident;
@@ -15,8 +15,7 @@ use crate::token::CustomToken;
///
/// This trait is sealed and cannot be implemented for types outside of Syn. It
/// is implemented only for `proc_macro2::Ident`.
-///
-/// *This trait is available only if Syn is built with the `"parsing"` feature.*
+#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub trait IdentExt: Sized + private::Sealed {
/// Parses any identifier including keywords.
///
diff --git a/src/file.rs b/src/file.rs
index 29a4a146d5..6b2ae6abc6 100644
--- a/src/file.rs
+++ b/src/file.rs
@@ -3,8 +3,6 @@ use super::*;
ast_struct! {
/// A complete file of Rust source code.
///
- /// *This type is available only if Syn is built with the `"full"` feature.*
- ///
/// # Example
///
/// Parse a Rust source file into a `syn::File` and print out a debug
@@ -67,6 +65,7 @@ ast_struct! {
/// ),
/// ...
/// ```
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct File {
pub shebang: Option,
pub attrs: Vec,
diff --git a/src/gen/fold.rs b/src/gen/fold.rs
index b472d14258..516ef340c6 100644
--- a/src/gen/fold.rs
+++ b/src/gen/fold.rs
@@ -25,8 +25,7 @@ macro_rules! full {
/// See the [module documentation] for details.
///
/// [module documentation]: self
-///
-/// *This trait is available only if Syn is built with the `"fold"` feature.*
+#[cfg_attr(docsrs, doc(cfg(feature = "fold")))]
pub trait Fold {
#[cfg(any(feature = "derive", feature = "full"))]
fn fold_abi(&mut self, i: Abi) -> Abi {
diff --git a/src/gen/visit.rs b/src/gen/visit.rs
index 24d34b7480..d0871428e8 100644
--- a/src/gen/visit.rs
+++ b/src/gen/visit.rs
@@ -28,8 +28,7 @@ macro_rules! skip {
/// See the [module documentation] for details.
///
/// [module documentation]: self
-///
-/// *This trait is available only if Syn is built with the `"visit"` feature.*
+#[cfg_attr(docsrs, doc(cfg(feature = "visit")))]
pub trait Visit<'ast> {
#[cfg(any(feature = "derive", feature = "full"))]
fn visit_abi(&mut self, i: &'ast Abi) {
diff --git a/src/gen/visit_mut.rs b/src/gen/visit_mut.rs
index 5ce11f0b2e..8718cc57fd 100644
--- a/src/gen/visit_mut.rs
+++ b/src/gen/visit_mut.rs
@@ -29,8 +29,7 @@ macro_rules! skip {
/// See the [module documentation] for details.
///
/// [module documentation]: self
-///
-/// *This trait is available only if Syn is built with the `"visit-mut"` feature.*
+#[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
pub trait VisitMut {
#[cfg(any(feature = "derive", feature = "full"))]
fn visit_abi_mut(&mut self, i: &mut Abi) {
diff --git a/src/generics.rs b/src/generics.rs
index d0015dbcba..d4fa9fde07 100644
--- a/src/generics.rs
+++ b/src/generics.rs
@@ -4,10 +4,8 @@ use crate::punctuated::{Iter, IterMut, Punctuated};
ast_struct! {
/// Lifetimes and type parameters attached to a declaration of a function,
/// enum, trait, etc.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
#[derive(Default)]
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Generics {
pub lt_token: Option,
pub params: Punctuated,
@@ -20,14 +18,12 @@ ast_enum_of_structs! {
/// A generic type parameter, lifetime, or const generic: `T: Into`,
/// `'a: 'b`, `const LEN: usize`.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
///
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum GenericParam {
/// A generic type parameter: `T: Into`.
Type(TypeParam),
@@ -42,9 +38,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A generic type parameter: `T: Into`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeParam {
pub attrs: Vec,
pub ident: Ident,
@@ -57,9 +51,7 @@ ast_struct! {
ast_struct! {
/// A lifetime definition: `'a: 'b + 'c + 'd`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct LifetimeDef {
pub attrs: Vec,
pub lifetime: Lifetime,
@@ -70,9 +62,7 @@ ast_struct! {
ast_struct! {
/// A const generic parameter: `const LENGTH: usize`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ConstParam {
pub attrs: Vec,
pub const_token: Token![const],
@@ -276,30 +266,24 @@ impl<'a> Iterator for ConstParamsMut<'a> {
}
/// Returned by `Generics::split_for_impl`.
-///
-/// *This type is available only if Syn is built with the `"derive"` or `"full"`
-/// feature and the `"printing"` feature.*
#[cfg(feature = "printing")]
#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
#[cfg_attr(feature = "clone-impls", derive(Clone))]
+#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ImplGenerics<'a>(&'a Generics);
/// Returned by `Generics::split_for_impl`.
-///
-/// *This type is available only if Syn is built with the `"derive"` or `"full"`
-/// feature and the `"printing"` feature.*
#[cfg(feature = "printing")]
#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
#[cfg_attr(feature = "clone-impls", derive(Clone))]
+#[cfg_attr(docsrs, doc(cfg(all(any(feature = "derive", feature = "full"), feature = "printing"))))]
pub struct TypeGenerics<'a>(&'a Generics);
/// Returned by `TypeGenerics::as_turbofish`.
-///
-/// *This type is available only if Syn is built with the `"derive"` or `"full"`
-/// feature and the `"printing"` feature.*
#[cfg(feature = "printing")]
#[cfg_attr(feature = "extra-traits", derive(Debug, Eq, PartialEq, Hash))]
#[cfg_attr(feature = "clone-impls", derive(Clone))]
+#[cfg_attr(docsrs, doc(cfg(all(any(feature = "derive", feature = "full"), feature = "printing"))))]
pub struct Turbofish<'a>(&'a Generics);
#[cfg(feature = "printing")]
@@ -322,9 +306,7 @@ impl Generics {
/// }
/// # ;
/// ```
- ///
- /// *This method is available only if Syn is built with the `"derive"` or
- /// `"full"` feature and the `"printing"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(all(any(feature = "derive", feature = "full"), feature = "printing"))))]
pub fn split_for_impl(&self) -> (ImplGenerics, TypeGenerics, Option<&WhereClause>) {
(
ImplGenerics(self),
@@ -337,9 +319,7 @@ impl Generics {
#[cfg(feature = "printing")]
impl<'a> TypeGenerics<'a> {
/// Turn a type's generics like `` into a turbofish like `::`.
- ///
- /// *This method is available only if Syn is built with the `"derive"` or
- /// `"full"` feature and the `"printing"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(all(any(feature = "derive", feature = "full"), feature = "printing"))))]
pub fn as_turbofish(&self) -> Turbofish {
Turbofish(self.0)
}
@@ -347,9 +327,7 @@ impl<'a> TypeGenerics<'a> {
ast_struct! {
/// A set of bound lifetimes: `for<'a, 'b, 'c>`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
#[derive(Default)]
pub struct BoundLifetimes {
pub for_token: Token![for],
@@ -385,9 +363,7 @@ impl From for TypeParam {
ast_enum_of_structs! {
/// A trait or lifetime used as a bound on a type parameter.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum TypeParamBound {
Trait(TraitBound),
Lifetime(Lifetime),
@@ -396,9 +372,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A trait used as a bound on a type parameter.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TraitBound {
pub paren_token: Option,
pub modifier: TraitBoundModifier,
@@ -412,9 +386,7 @@ ast_struct! {
ast_enum! {
/// A modifier on a trait bound, currently only used for the `?` in
/// `?Sized`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
#[cfg_attr(feature = "clone-impls", derive(Copy))]
pub enum TraitBoundModifier {
None,
@@ -425,9 +397,7 @@ ast_enum! {
ast_struct! {
/// A `where` clause in a definition: `where T: Deserialize<'de>, D:
/// 'static`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct WhereClause {
pub where_token: Token![where],
pub predicates: Punctuated,
@@ -436,9 +406,7 @@ ast_struct! {
ast_enum_of_structs! {
/// A single predicate in a `where` clause: `T: Deserialize<'de>`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
///
/// # Syntax tree enum
///
@@ -459,9 +427,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct PredicateType {
/// Any lifetimes from a `for` binding
pub lifetimes: Option,
@@ -475,9 +441,7 @@ ast_struct! {
ast_struct! {
/// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct PredicateLifetime {
pub lifetime: Lifetime,
pub colon_token: Token![:],
@@ -487,9 +451,7 @@ ast_struct! {
ast_struct! {
/// An equality predicate in a `where` clause (unsupported).
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct PredicateEq {
pub lhs_ty: Type,
pub eq_token: Token![=],
diff --git a/src/item.rs b/src/item.rs
index 9a59227e2a..2a6c106b3e 100644
--- a/src/item.rs
+++ b/src/item.rs
@@ -13,8 +13,6 @@ use std::mem;
ast_enum_of_structs! {
/// Things that can appear directly inside of a module or scope.
///
- /// *This type is available only if Syn is built with the `"full"` feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -23,6 +21,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum Item #manual_extra_traits {
/// A constant item: `const MAX: u16 = 65535`.
Const(ItemConst),
@@ -84,8 +83,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A constant item: `const MAX: u16 = 65535`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemConst {
pub attrs: Vec,
pub vis: Visibility,
@@ -101,8 +99,7 @@ ast_struct! {
ast_struct! {
/// An enum definition: `enum Foo { A(A), B(B) }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemEnum {
pub attrs: Vec,
pub vis: Visibility,
@@ -116,8 +113,7 @@ ast_struct! {
ast_struct! {
/// An `extern crate` item: `extern crate serde`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemExternCrate {
pub attrs: Vec,
pub vis: Visibility,
@@ -132,8 +128,7 @@ ast_struct! {
ast_struct! {
/// A free-standing function: `fn process(n: usize) -> Result<()> { ...
/// }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemFn {
pub attrs: Vec,
pub vis: Visibility,
@@ -144,8 +139,7 @@ ast_struct! {
ast_struct! {
/// A block of foreign items: `extern "C" { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemForeignMod {
pub attrs: Vec,
pub abi: Abi,
@@ -157,8 +151,7 @@ ast_struct! {
ast_struct! {
/// An impl block providing trait or associated items: `impl Trait
/// for Data { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemImpl {
pub attrs: Vec,
pub defaultness: Option,
@@ -176,8 +169,7 @@ ast_struct! {
ast_struct! {
/// A macro invocation, which includes `macro_rules!` definitions.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemMacro {
pub attrs: Vec,
/// The `example` in `macro_rules! example { ... }`.
@@ -189,8 +181,7 @@ ast_struct! {
ast_struct! {
/// A 2.0-style declarative macro introduced by the `macro` keyword.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemMacro2 #manual_extra_traits {
pub attrs: Vec,
pub vis: Visibility,
@@ -202,8 +193,7 @@ ast_struct! {
ast_struct! {
/// A module or module declaration: `mod m` or `mod m { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemMod {
pub attrs: Vec,
pub vis: Visibility,
@@ -216,8 +206,7 @@ ast_struct! {
ast_struct! {
/// A static item: `static BIKE: Shed = Shed(42)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemStatic {
pub attrs: Vec,
pub vis: Visibility,
@@ -234,8 +223,7 @@ ast_struct! {
ast_struct! {
/// A struct definition: `struct Foo { x: A }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemStruct {
pub attrs: Vec,
pub vis: Visibility,
@@ -249,8 +237,7 @@ ast_struct! {
ast_struct! {
/// A trait definition: `pub trait Iterator { ... }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemTrait {
pub attrs: Vec,
pub vis: Visibility,
@@ -268,8 +255,7 @@ ast_struct! {
ast_struct! {
/// A trait alias: `pub trait SharableIterator = Iterator + Sync`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemTraitAlias {
pub attrs: Vec,
pub vis: Visibility,
@@ -284,8 +270,7 @@ ast_struct! {
ast_struct! {
/// A type alias: `type Result = std::result::Result`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemType {
pub attrs: Vec,
pub vis: Visibility,
@@ -300,8 +285,7 @@ ast_struct! {
ast_struct! {
/// A union definition: `union Foo { x: A, y: B }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemUnion {
pub attrs: Vec,
pub vis: Visibility,
@@ -314,8 +298,7 @@ ast_struct! {
ast_struct! {
/// A use declaration: `use std::collections::HashMap`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ItemUse {
pub attrs: Vec,
pub vis: Visibility,
@@ -574,8 +557,6 @@ impl From for DeriveInput {
ast_enum_of_structs! {
/// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`.
///
- /// *This type is available only if Syn is built with the `"full"` feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -584,6 +565,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum UseTree {
/// A path prefix of imports in a `use` item: `std::...`.
Path(UsePath),
@@ -604,8 +586,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A path prefix of imports in a `use` item: `std::...`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct UsePath {
pub ident: Ident,
pub colon2_token: Token![::],
@@ -615,8 +596,7 @@ ast_struct! {
ast_struct! {
/// An identifier imported by a `use` item: `HashMap`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct UseName {
pub ident: Ident,
}
@@ -624,8 +604,7 @@ ast_struct! {
ast_struct! {
/// An renamed identifier imported by a `use` item: `HashMap as Map`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct UseRename {
pub ident: Ident,
pub as_token: Token![as],
@@ -635,8 +614,7 @@ ast_struct! {
ast_struct! {
/// A glob import in a `use` item: `*`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct UseGlob {
pub star_token: Token![*],
}
@@ -644,8 +622,7 @@ ast_struct! {
ast_struct! {
/// A braced group of imports in a `use` item: `{A, B, C}`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct UseGroup {
pub brace_token: token::Brace,
pub items: Punctuated,
@@ -654,8 +631,7 @@ ast_struct! {
ast_enum_of_structs! {
/// An item within an `extern` block.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
///
/// # Syntax tree enum
///
@@ -688,8 +664,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A foreign function in an `extern` block.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ForeignItemFn {
pub attrs: Vec,
pub vis: Visibility,
@@ -700,8 +675,7 @@ ast_struct! {
ast_struct! {
/// A foreign static item in an `extern` block: `static ext: u8`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ForeignItemStatic {
pub attrs: Vec,
pub vis: Visibility,
@@ -716,8 +690,7 @@ ast_struct! {
ast_struct! {
/// A foreign type in an `extern` block: `type void`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ForeignItemType {
pub attrs: Vec,
pub vis: Visibility,
@@ -729,8 +702,7 @@ ast_struct! {
ast_struct! {
/// A macro invocation within an extern block.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ForeignItemMacro {
pub attrs: Vec,
pub mac: Macro,
@@ -792,8 +764,6 @@ impl Hash for ForeignItem {
ast_enum_of_structs! {
/// An item declaration within the definition of a trait.
///
- /// *This type is available only if Syn is built with the `"full"` feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -802,6 +772,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum TraitItem #manual_extra_traits {
/// An associated constant within the definition of a trait.
Const(TraitItemConst),
@@ -825,8 +796,7 @@ ast_enum_of_structs! {
ast_struct! {
/// An associated constant within the definition of a trait.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct TraitItemConst {
pub attrs: Vec,
pub const_token: Token![const],
@@ -840,8 +810,7 @@ ast_struct! {
ast_struct! {
/// A trait method within the definition of a trait.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct TraitItemMethod {
pub attrs: Vec,
pub sig: Signature,
@@ -852,8 +821,7 @@ ast_struct! {
ast_struct! {
/// An associated type within the definition of a trait.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct TraitItemType {
pub attrs: Vec,
pub type_token: Token![type],
@@ -868,8 +836,7 @@ ast_struct! {
ast_struct! {
/// A macro invocation within the definition of a trait.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct TraitItemMacro {
pub attrs: Vec,
pub mac: Macro,
@@ -931,8 +898,6 @@ impl Hash for TraitItem {
ast_enum_of_structs! {
/// An item within an impl block.
///
- /// *This type is available only if Syn is built with the `"full"` feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -941,6 +906,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum ImplItem #manual_extra_traits {
/// An associated constant within an impl block.
Const(ImplItemConst),
@@ -964,8 +930,7 @@ ast_enum_of_structs! {
ast_struct! {
/// An associated constant within an impl block.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ImplItemConst {
pub attrs: Vec,
pub vis: Visibility,
@@ -982,8 +947,7 @@ ast_struct! {
ast_struct! {
/// A method within an impl block.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ImplItemMethod {
pub attrs: Vec,
pub vis: Visibility,
@@ -995,8 +959,7 @@ ast_struct! {
ast_struct! {
/// An associated type within an impl block.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ImplItemType {
pub attrs: Vec,
pub vis: Visibility,
@@ -1012,8 +975,7 @@ ast_struct! {
ast_struct! {
/// A macro invocation within an impl block.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct ImplItemMacro {
pub attrs: Vec,
pub mac: Macro,
@@ -1075,8 +1037,7 @@ impl Hash for ImplItem {
ast_struct! {
/// A function signature in a trait or implementation: `unsafe fn
/// initialize(&self)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct Signature {
pub constness: Option,
pub asyncness: Option,
@@ -1112,8 +1073,7 @@ impl Signature {
ast_enum_of_structs! {
/// An argument in a function signature: the `n: usize` in `fn f(n: usize)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum FnArg {
/// The `self` argument of an associated method, whether taken by value
/// or by reference.
@@ -1133,8 +1093,7 @@ ast_struct! {
///
/// Note that `self` receivers with a specified type, such as `self:
/// Box`, are parsed as a `FnArg::Typed`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct Receiver {
pub attrs: Vec,
pub reference: Option<(Token![&], Option)>,
diff --git a/src/lib.rs b/src/lib.rs
index c220141eaf..b20b46bac8 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -251,6 +251,7 @@
// Syn types in rustdoc of other crates get linked to here.
#![doc(html_root_url = "https://docs.rs/syn/1.0.27")]
+#![cfg_attr(docsrs, feature(doc_cfg))]
#![deny(clippy::all, clippy::pedantic)]
// Ignored clippy lints.
#![allow(
@@ -495,10 +496,6 @@ mod gen {
/// /* ... */
/// ```
///
- /// *This module is available only if Syn is built with the `"visit"` feature.*
- ///
- ///
- ///
/// # Example
///
/// This visitor will print the name of every freestanding function in the
@@ -572,6 +569,7 @@ mod gen {
/// }
/// ```
#[cfg(feature = "visit")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "visit")))]
#[rustfmt::skip]
pub mod visit;
@@ -616,11 +614,6 @@ mod gen {
/// /* ... */
/// ```
///
- /// *This module is available only if Syn is built with the `"visit-mut"`
- /// feature.*
- ///
- ///
- ///
/// # Example
///
/// This mut visitor replace occurrences of u256 suffixed integer literals
@@ -668,6 +661,7 @@ mod gen {
/// }
/// ```
#[cfg(feature = "visit-mut")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "visit-mut")))]
#[rustfmt::skip]
pub mod visit_mut;
@@ -715,10 +709,6 @@ mod gen {
/// /* ... */
/// ```
///
- /// *This module is available only if Syn is built with the `"fold"` feature.*
- ///
- ///
- ///
/// # Example
///
/// This fold inserts parentheses to fully parenthesizes any expression.
@@ -754,6 +744,7 @@ mod gen {
/// }
/// ```
#[cfg(feature = "fold")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "fold")))]
#[rustfmt::skip]
pub mod fold;
@@ -814,9 +805,6 @@ pub use crate::error::{Error, Result};
///
/// [`syn::parse2`]: parse2
///
-/// *This function is available only if Syn is built with both the `"parsing"` and
-/// `"proc-macro"` features.*
-///
/// # Examples
///
/// ```
@@ -847,6 +835,7 @@ pub use crate::error::{Error, Result};
feature = "parsing",
feature = "proc-macro"
))]
+#[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "proc-macro"))))]
pub fn parse(tokens: proc_macro::TokenStream) -> Result {
parse::Parser::parse(T::parse, tokens)
}
@@ -860,17 +849,14 @@ pub fn parse(tokens: proc_macro::TokenStream) -> Result {
/// instead.
///
/// [`syn::parse`]: parse()
-///
-/// *This function is available only if Syn is built with the `"parsing"` feature.*
#[cfg(feature = "parsing")]
+#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse2(tokens: proc_macro2::TokenStream) -> Result {
parse::Parser::parse2(T::parse, tokens)
}
/// Parse a string of Rust code into the chosen syntax tree node.
///
-/// *This function is available only if Syn is built with the `"parsing"` feature.*
-///
/// # Hygiene
///
/// Every span in the resulting syntax tree will be set to resolve at the macro
@@ -891,6 +877,7 @@ pub fn parse2(tokens: proc_macro2::TokenStream) -> Result {
/// # run().unwrap();
/// ```
#[cfg(feature = "parsing")]
+#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_str(s: &str) -> Result {
parse::Parser::parse_str(T::parse, s)
}
@@ -906,9 +893,6 @@ pub fn parse_str(s: &str) -> Result {
///
/// If present, either of these would be an error using `from_str`.
///
-/// *This function is available only if Syn is built with the `"parsing"` and
-/// `"full"` features.*
-///
/// # Examples
///
/// ```no_run
@@ -933,6 +917,7 @@ pub fn parse_str(s: &str) -> Result {
/// # run().unwrap();
/// ```
#[cfg(all(feature = "parsing", feature = "full"))]
+#[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "full"))))]
pub fn parse_file(mut content: &str) -> Result {
// Strip the BOM if it is present
const BOM: &str = "\u{feff}";
diff --git a/src/lifetime.rs b/src/lifetime.rs
index d34df34b81..816fca0812 100644
--- a/src/lifetime.rs
+++ b/src/lifetime.rs
@@ -17,11 +17,9 @@ use crate::lookahead;
/// the XID_Start property.
/// - All following characters must be Unicode code points with the XID_Continue
/// property.
-///
-/// *This type is available only if Syn is built with the `"derive"` or `"full"`
-/// feature.*
#[cfg_attr(feature = "extra-traits", derive(Debug))]
#[derive(Clone)]
+#[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Lifetime {
pub apostrophe: Span,
pub ident: Ident,
diff --git a/src/mac.rs b/src/mac.rs
index 2d94c95181..decbc450d7 100644
--- a/src/mac.rs
+++ b/src/mac.rs
@@ -13,9 +13,7 @@ use std::hash::{Hash, Hasher};
ast_struct! {
/// A macro invocation: `println!("{}", mac)`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Macro #manual_extra_traits {
pub path: Path,
pub bang_token: Token![!],
@@ -26,9 +24,7 @@ ast_struct! {
ast_enum! {
/// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum MacroDelimiter {
Paren(Paren),
Brace(Brace),
diff --git a/src/op.rs b/src/op.rs
index e0e7809f69..04e8edf804 100644
--- a/src/op.rs
+++ b/src/op.rs
@@ -1,9 +1,7 @@
ast_enum! {
/// A binary operator: `+`, `+=`, `&`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
#[cfg_attr(feature = "clone-impls", derive(Copy))]
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum BinOp {
/// The `+` operator (addition)
Add(Token![+]),
@@ -66,10 +64,8 @@ ast_enum! {
ast_enum! {
/// A unary operator: `*`, `!`, `-`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
#[cfg_attr(feature = "clone-impls", derive(Copy))]
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum UnOp {
/// The `*` operator for dereferencing
Deref(Token![*]),
diff --git a/src/parse.rs b/src/parse.rs
index f9ef69cde1..9023ba6bca 100644
--- a/src/parse.rs
+++ b/src/parse.rs
@@ -183,8 +183,8 @@
//! ```
//!
//! ---
-//!
-//! *This module is available only if Syn is built with the `"parsing"` feature.*
+
+#![cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
#[path = "discouraged.rs"]
pub mod discouraged;
@@ -1093,8 +1093,7 @@ impl Parse for Literal {
/// Refer to the [module documentation] for details about parsing in Syn.
///
/// [module documentation]: self
-///
-/// *This trait is available only if Syn is built with the `"parsing"` feature.*
+#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub trait Parser: Sized {
type Output;
@@ -1108,13 +1107,11 @@ pub trait Parser: Sized {
///
/// This function will check that the input is fully parsed. If there are
/// any unparsed tokens at the end of the stream, an error is returned.
- ///
- /// *This method is available only if Syn is built with both the `"parsing"` and
- /// `"proc-macro"` features.*
#[cfg(all(
not(all(target_arch = "wasm32", any(target_os = "unknown", target_os = "wasi"))),
feature = "proc-macro"
))]
+ #[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "proc-macro"))))]
fn parse(self, tokens: proc_macro::TokenStream) -> Result {
self.parse2(proc_macro2::TokenStream::from(tokens))
}
diff --git a/src/parse_quote.rs b/src/parse_quote.rs
index 66aa818cd0..fe4cf1cbf2 100644
--- a/src/parse_quote.rs
+++ b/src/parse_quote.rs
@@ -69,6 +69,7 @@
//
// TODO: allow Punctuated to be inferred as intra doc link, currently blocked on
// https://github.com/rust-lang/rust/issues/62834
+#[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
#[macro_export]
macro_rules! parse_quote {
($($tt:tt)*) => {
diff --git a/src/pat.rs b/src/pat.rs
index 68d58dc55b..daedf6de98 100644
--- a/src/pat.rs
+++ b/src/pat.rs
@@ -10,8 +10,6 @@ ast_enum_of_structs! {
/// A pattern in a local binding, function signature, match expression, or
/// various other places.
///
- /// *This type is available only if Syn is built with the `"full"` feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -20,6 +18,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum Pat #manual_extra_traits {
/// A box pattern: `box v`.
Box(PatBox),
@@ -85,8 +84,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A box pattern: `box v`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatBox {
pub attrs: Vec,
pub box_token: Token![box],
@@ -99,8 +97,7 @@ ast_struct! {
///
/// It may also be a unit struct or struct variant (e.g. `None`), or a
/// constant; these cannot be distinguished syntactically.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatIdent {
pub attrs: Vec,
pub by_ref: Option,
@@ -115,8 +112,7 @@ ast_struct! {
///
/// This holds an `Expr` rather than a `Lit` because negative numbers
/// are represented as an `Expr::Unary`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatLit {
pub attrs: Vec,
pub expr: Box,
@@ -125,8 +121,7 @@ ast_struct! {
ast_struct! {
/// A macro in pattern position.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatMacro {
pub attrs: Vec,
pub mac: Macro,
@@ -135,8 +130,7 @@ ast_struct! {
ast_struct! {
/// A pattern that matches any one of a set of cases.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatOr {
pub attrs: Vec,
pub leading_vert: Option,
@@ -152,8 +146,7 @@ ast_struct! {
/// constants or associated constants. Qualified path patterns like
/// `::B::C` and ` ::B::C` can only legally refer to
/// associated constants.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatPath {
pub attrs: Vec,
pub qself: Option,
@@ -163,8 +156,7 @@ ast_struct! {
ast_struct! {
/// A range pattern: `1..=2`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatRange {
pub attrs: Vec,
pub lo: Box,
@@ -175,8 +167,7 @@ ast_struct! {
ast_struct! {
/// A reference pattern: `&mut var`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatReference {
pub attrs: Vec,
pub and_token: Token![&],
@@ -187,8 +178,7 @@ ast_struct! {
ast_struct! {
/// The dots in a tuple or slice pattern: `[0, 1, ..]`
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatRest {
pub attrs: Vec,
pub dot2_token: Token![..],
@@ -197,8 +187,7 @@ ast_struct! {
ast_struct! {
/// A dynamically sized slice pattern: `[a, b, ref i @ .., y, z]`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatSlice {
pub attrs: Vec,
pub bracket_token: token::Bracket,
@@ -208,8 +197,7 @@ ast_struct! {
ast_struct! {
/// A struct or struct variant pattern: `Variant { x, y, .. }`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatStruct {
pub attrs: Vec,
pub path: Path,
@@ -221,8 +209,7 @@ ast_struct! {
ast_struct! {
/// A tuple pattern: `(a, b)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatTuple {
pub attrs: Vec,
pub paren_token: token::Paren,
@@ -232,8 +219,7 @@ ast_struct! {
ast_struct! {
/// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatTupleStruct {
pub attrs: Vec,
pub path: Path,
@@ -243,8 +229,7 @@ ast_struct! {
ast_struct! {
/// A type ascription pattern: `foo: f64`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatType {
pub attrs: Vec,
pub pat: Box,
@@ -255,8 +240,7 @@ ast_struct! {
ast_struct! {
/// A pattern that matches any value: `_`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct PatWild {
pub attrs: Vec,
pub underscore_token: Token![_],
@@ -268,8 +252,7 @@ ast_struct! {
///
/// Patterns like the fields of Foo `{ x, ref y, ref mut z }` are treated
/// the same as `x: x, y: ref y, z: ref mut z` but there is no colon token.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct FieldPat {
pub attrs: Vec,
pub member: Member,
diff --git a/src/path.rs b/src/path.rs
index 15c0fcc664..697556cbaf 100644
--- a/src/path.rs
+++ b/src/path.rs
@@ -3,9 +3,7 @@ use crate::punctuated::Punctuated;
ast_struct! {
/// A path at which a named item is exported (e.g. `std::collections::HashMap`).
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Path {
pub leading_colon: Option,
pub segments: Punctuated,
@@ -28,9 +26,7 @@ where
ast_struct! {
/// A segment of a path together with any path arguments on that segment.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct PathSegment {
pub ident: Ident,
pub arguments: PathArguments,
@@ -51,9 +47,7 @@ where
ast_enum! {
/// Angle bracketed or parenthesized arguments of a path segment.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
///
/// ## Angle bracketed
///
@@ -97,9 +91,7 @@ impl PathArguments {
ast_enum! {
/// An individual generic argument, like `'a`, `T`, or `Item = T`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum GenericArgument {
/// A lifetime argument.
Lifetime(Lifetime),
@@ -121,9 +113,7 @@ ast_enum! {
ast_struct! {
/// Angle bracketed arguments of a path segment: the `` in `HashMap`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct AngleBracketedGenericArguments {
pub colon2_token: Option,
pub lt_token: Token![<],
@@ -134,9 +124,7 @@ ast_struct! {
ast_struct! {
/// A binding (equality constraint) on an associated type: `Item = u8`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Binding {
pub ident: Ident,
pub eq_token: Token![=],
@@ -146,9 +134,7 @@ ast_struct! {
ast_struct! {
/// An associated type bound: `Iterator`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Constraint {
pub ident: Ident,
pub colon_token: Token![:],
@@ -159,9 +145,7 @@ ast_struct! {
ast_struct! {
/// Arguments of a function path segment: the `(A, B) -> C` in `Fn(A,B) ->
/// C`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct ParenthesizedGenericArguments {
pub paren_token: token::Paren,
/// `(A, B)`
@@ -188,9 +172,7 @@ ast_struct! {
/// ^~~~~~ ^
/// ty position = 0
/// ```
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct QSelf {
pub lt_token: Token![<],
pub ty: Box,
@@ -354,9 +336,6 @@ pub mod parsing {
impl Path {
/// Parse a `Path` containing no path arguments on any of its segments.
///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
- ///
/// # Example
///
/// ```
@@ -385,6 +364,7 @@ pub mod parsing {
/// }
/// }
/// ```
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_mod_style(input: ParseStream) -> Result {
Ok(Path {
leading_colon: input.parse()?,
@@ -428,9 +408,6 @@ pub mod parsing {
/// path arguments, and
/// - the ident of the first path segment is equal to the given one.
///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
- ///
/// # Example
///
/// ```
@@ -448,6 +425,7 @@ pub mod parsing {
/// }
/// }
/// ```
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn is_ident(&self, ident: &I) -> bool
where
Ident: PartialEq,
@@ -466,9 +444,7 @@ pub mod parsing {
/// - the number of path segments is 1, and
/// - the first path segment has no angle bracketed or parenthesized
/// path arguments.
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn get_ident(&self) -> Option<&Ident> {
if self.leading_colon.is_none()
&& self.segments.len() == 1
diff --git a/src/punctuated.rs b/src/punctuated.rs
index cdd25c06a7..0cef93ac74 100644
--- a/src/punctuated.rs
+++ b/src/punctuated.rs
@@ -238,10 +238,8 @@ impl Punctuated {
///
/// Parsing continues until the end of this parse stream. The entire content
/// of this parse stream must consist of `T` and `P`.
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_terminated(input: ParseStream) -> Result
where
T: Parse,
@@ -258,10 +256,8 @@ impl Punctuated {
/// to be parsed.
///
/// [`parse_terminated`]: Punctuated::parse_terminated
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_terminated_with(
input: ParseStream,
parser: fn(ParseStream) -> Result,
@@ -294,10 +290,8 @@ impl Punctuated {
/// the stream. This method returns upon parsing a `T` and observing that it
/// is not followed by a `P`, even if there are remaining tokens in the
/// stream.
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_separated_nonempty(input: ParseStream) -> Result
where
T: Parse,
@@ -314,10 +308,8 @@ impl Punctuated {
/// the entire content of this stream.
///
/// [`parse_separated_nonempty`]: Punctuated::parse_separated_nonempty
- ///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
#[cfg(feature = "parsing")]
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_separated_nonempty_with(
input: ParseStream,
parser: fn(ParseStream) -> Result,
diff --git a/src/spanned.rs b/src/spanned.rs
index 01591cedcb..e43b2c1997 100644
--- a/src/spanned.rs
+++ b/src/spanned.rs
@@ -1,11 +1,6 @@
//! A trait that can provide the `Span` of the complete contents of a syntax
//! tree node.
//!
-//! *This module is available only if Syn is built with both the `"parsing"` and
-//! `"printing"` features.*
-//!
-//!
-//!
//! # Example
//!
//! Suppose in a procedural macro we have a [`Type`] that we want to assert
@@ -81,6 +76,7 @@
//! needing the unstable `join`.
//!
//! [`syn::Error::new_spanned`]: crate::Error::new_spanned
+#![cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "printing"))))]
use proc_macro2::Span;
use quote::spanned::Spanned as ToTokens;
@@ -96,9 +92,7 @@ use quote::spanned::Spanned as ToTokens;
/// See the [module documentation] for an example.
///
/// [module documentation]: self
-///
-/// *This trait is available only if Syn is built with both the `"parsing"` and
-/// `"printing"` features.*
+#[cfg_attr(docsrs, doc(cfg(all(feature = "parsing", feature = "printing"))))]
pub trait Spanned {
/// Returns a `Span` covering the complete contents of this syntax tree
/// node, or [`Span::call_site()`] if this node is empty.
diff --git a/src/stmt.rs b/src/stmt.rs
index b06e843d75..f13f6970e8 100644
--- a/src/stmt.rs
+++ b/src/stmt.rs
@@ -2,8 +2,7 @@ use super::*;
ast_struct! {
/// A braced block containing Rust statements.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct Block {
pub brace_token: token::Brace,
/// Statements in a block
@@ -13,8 +12,7 @@ ast_struct! {
ast_enum! {
/// A statement, usually ending in a semicolon.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub enum Stmt {
/// A local (let) binding.
Local(Local),
@@ -32,8 +30,7 @@ ast_enum! {
ast_struct! {
/// A local `let` binding: `let x: u64 = s.parse()?`.
- ///
- /// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(feature = "full")))]
pub struct Local {
pub attrs: Vec,
pub let_token: Token![let],
@@ -55,9 +52,6 @@ pub mod parsing {
/// Parse the body of a block as zero or more statements, possibly
/// including one trailing expression.
///
- /// *This function is available only if Syn is built with the `"parsing"`
- /// feature.*
- ///
/// # Example
///
/// ```
@@ -104,6 +98,7 @@ pub mod parsing {
/// }
/// }
/// ```
+ #[cfg_attr(docsrs, doc(cfg(feature = "parsing")))]
pub fn parse_within(input: ParseStream) -> Result> {
let mut stmts = Vec::new();
loop {
diff --git a/src/ty.rs b/src/ty.rs
index a0b3df84d6..68c422e49c 100644
--- a/src/ty.rs
+++ b/src/ty.rs
@@ -9,9 +9,6 @@ use std::hash::{Hash, Hasher};
ast_enum_of_structs! {
/// The possible types that a Rust value could have.
///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
- ///
/// # Syntax tree enum
///
/// This type is a [syntax tree enum].
@@ -20,6 +17,7 @@ ast_enum_of_structs! {
//
// TODO: change syntax-tree-enum link to an intra rustdoc link, currently
// blocked on https://github.com/rust-lang/rust/issues/62833
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum Type #manual_extra_traits {
/// A fixed size array type: `[T; n]`.
Array(TypeArray),
@@ -76,9 +74,7 @@ ast_enum_of_structs! {
ast_struct! {
/// A fixed size array type: `[T; n]`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeArray {
pub bracket_token: token::Bracket,
pub elem: Box,
@@ -89,9 +85,7 @@ ast_struct! {
ast_struct! {
/// A bare function type: `fn(usize) -> bool`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeBareFn {
pub lifetimes: Option,
pub unsafety: Option,
@@ -106,9 +100,7 @@ ast_struct! {
ast_struct! {
/// A type contained within invisible delimiters.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeGroup {
pub group_token: token::Group,
pub elem: Box,
@@ -118,9 +110,7 @@ ast_struct! {
ast_struct! {
/// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or
/// a lifetime.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeImplTrait {
pub impl_token: Token![impl],
pub bounds: Punctuated,
@@ -129,9 +119,7 @@ ast_struct! {
ast_struct! {
/// Indication that a type should be inferred by the compiler: `_`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeInfer {
pub underscore_token: Token![_],
}
@@ -139,9 +127,7 @@ ast_struct! {
ast_struct! {
/// A macro in the type position.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeMacro {
pub mac: Macro,
}
@@ -149,9 +135,7 @@ ast_struct! {
ast_struct! {
/// The never type: `!`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeNever {
pub bang_token: Token![!],
}
@@ -159,9 +143,7 @@ ast_struct! {
ast_struct! {
/// A parenthesized type equivalent to the inner type.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeParen {
pub paren_token: token::Paren,
pub elem: Box,
@@ -171,9 +153,7 @@ ast_struct! {
ast_struct! {
/// A path like `std::slice::Iter`, optionally qualified with a
/// self-type as in ` as SomeTrait>::Associated`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypePath {
pub qself: Option,
pub path: Path,
@@ -182,9 +162,7 @@ ast_struct! {
ast_struct! {
/// A raw pointer type: `*const T` or `*mut T`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypePtr {
pub star_token: Token![*],
pub const_token: Option,
@@ -195,9 +173,7 @@ ast_struct! {
ast_struct! {
/// A reference type: `&'a T` or `&'a mut T`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeReference {
pub and_token: Token![&],
pub lifetime: Option,
@@ -208,9 +184,7 @@ ast_struct! {
ast_struct! {
/// A dynamically sized slice type: `[T]`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeSlice {
pub bracket_token: token::Bracket,
pub elem: Box,
@@ -220,9 +194,7 @@ ast_struct! {
ast_struct! {
/// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a
/// trait or a lifetime.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeTraitObject {
pub dyn_token: Option,
pub bounds: Punctuated,
@@ -231,9 +203,7 @@ ast_struct! {
ast_struct! {
/// A tuple type: `(A, B, C, String)`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or
- /// `"full"` feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct TypeTuple {
pub paren_token: token::Paren,
pub elems: Punctuated,
@@ -343,9 +313,7 @@ impl Hash for Type {
ast_struct! {
/// The binary interface of a function: `extern "C"`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Abi {
pub extern_token: Token![extern],
pub name: Option,
@@ -354,9 +322,7 @@ ast_struct! {
ast_struct! {
/// An argument in a function type: the `usize` in `fn(usize) -> bool`.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct BareFnArg {
pub attrs: Vec,
pub name: Option<(Ident, Token![:])>,
@@ -376,9 +342,7 @@ ast_struct! {
/// // ^^^
/// }
/// ```
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub struct Variadic {
pub attrs: Vec,
pub dots: Token![...],
@@ -387,9 +351,7 @@ ast_struct! {
ast_enum! {
/// Return type of a function signature.
- ///
- /// *This type is available only if Syn is built with the `"derive"` or `"full"`
- /// feature.*
+ #[cfg_attr(docsrs, doc(cfg(any(feature = "derive", feature = "full"))))]
pub enum ReturnType {
/// Return type is not specified.
///