///
/// This type is a [syntax tree enum].
///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
+ /// [syntax tree enum]: Expr#syntax-tree-enums
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub enum Item {
/// A constant item: `const MAX: u16 = 65535`.
Const(ItemConst),
/// Tokens forming an item not interpreted by Syn.
Verbatim(TokenStream),
+ // The following is the only supported idiom for exhaustive matching of
+ // this enum.
+ //
+ // match expr {
+ // Item::Const(e) => {...}
+ // Item::Enum(e) => {...}
+ // ...
+ // Item::Verbatim(e) => {...}
+ //
+ // #[cfg(test)]
+ // Item::__TestExhaustive(_) => unimplemented!(),
+ // #[cfg(not(test))]
+ // _ => { /* some sane fallback */ }
+ // }
+ //
+ // This way we fail your tests but don't break your library when adding
+ // a variant. You will be notified by a test failure when a variant is
+ // added, so that you can add code to handle it, but your library will
+ // continue to compile and work for downstream users in the interim.
+ //
+ // Once `deny(reachable)` is available in rustc, Item will be
+ // reimplemented as a non_exhaustive enum.
+ // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237
#[doc(hidden)]
- __Nonexhaustive,
+ __TestExhaustive(crate::private),
}
}
/// A constant item: `const MAX: u16 = 65535`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemConst {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// An enum definition: `enum Foo<A, B> { A(A), B(B) }`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemEnum {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// An `extern crate` item: `extern crate serde`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemExternCrate {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// }`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemFn {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A block of foreign items: `extern "C" { ... }`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemForeignMod {
pub attrs: Vec<Attribute>,
pub abi: Abi,
/// for Data<A> { ... }`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemImpl {
pub attrs: Vec<Attribute>,
pub defaultness: Option<Token![default]>,
/// A macro invocation, which includes `macro_rules!` definitions.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemMacro {
pub attrs: Vec<Attribute>,
/// The `example` in `macro_rules! example { ... }`.
/// 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(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemMacro2 {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// 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(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemMod {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A static item: `static BIKE: Shed = Shed(42)`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemStatic {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A struct definition: `struct Foo<A> { x: A }`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemStruct {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A trait definition: `pub trait Iterator { ... }`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemTrait {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A trait alias: `pub trait SharableIterator = Iterator + Sync`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemTraitAlias {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A type alias: `type Result<T> = std::result::Result<T, MyError>`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemType {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A union definition: `union Foo<A, B> { x: A, y: B }`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemUnion {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A use declaration: `use std::collections::HashMap`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ItemUse {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
| Item::Macro(ItemMacro { attrs, .. })
| Item::Macro2(ItemMacro2 { attrs, .. }) => mem::replace(attrs, new),
Item::Verbatim(_) => Vec::new(),
- Item::__Nonexhaustive => unreachable!(),
+
+ #[cfg(test)]
+ Item::__TestExhaustive(_) => unimplemented!(),
+ #[cfg(not(test))]
+ _ => unreachable!(),
}
}
}
///
/// This type is a [syntax tree enum].
///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
+ /// [syntax tree enum]: Expr#syntax-tree-enums
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub enum UseTree {
/// A path prefix of imports in a `use` item: `std::...`.
Path(UsePath),
/// 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(doc_cfg, doc(cfg(feature = "full")))]
pub struct UsePath {
pub ident: Ident,
pub colon2_token: Token![::],
/// An identifier imported by a `use` item: `HashMap`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct UseName {
pub ident: Ident,
}
/// 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(doc_cfg, doc(cfg(feature = "full")))]
pub struct UseRename {
pub ident: Ident,
pub as_token: Token![as],
/// A glob import in a `use` item: `*`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct UseGlob {
pub star_token: Token![*],
}
/// 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(doc_cfg, doc(cfg(feature = "full")))]
pub struct UseGroup {
pub brace_token: token::Brace,
pub items: Punctuated<UseTree, Token![,]>,
///
/// This type is a [syntax tree enum].
///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
+ /// [syntax tree enum]: Expr#syntax-tree-enums
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub enum ForeignItem {
/// A foreign function in an `extern` block.
Fn(ForeignItemFn),
/// Tokens in an `extern` block not interpreted by Syn.
Verbatim(TokenStream),
+ // The following is the only supported idiom for exhaustive matching of
+ // this enum.
+ //
+ // match expr {
+ // ForeignItem::Fn(e) => {...}
+ // ForeignItem::Static(e) => {...}
+ // ...
+ // ForeignItem::Verbatim(e) => {...}
+ //
+ // #[cfg(test)]
+ // ForeignItem::__TestExhaustive(_) => unimplemented!(),
+ // #[cfg(not(test))]
+ // _ => { /* some sane fallback */ }
+ // }
+ //
+ // This way we fail your tests but don't break your library when adding
+ // a variant. You will be notified by a test failure when a variant is
+ // added, so that you can add code to handle it, but your library will
+ // continue to compile and work for downstream users in the interim.
+ //
+ // Once `deny(reachable)` is available in rustc, ForeignItem will be
+ // reimplemented as a non_exhaustive enum.
+ // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237
#[doc(hidden)]
- __Nonexhaustive,
+ __TestExhaustive(crate::private),
}
}
/// A foreign function in an `extern` block.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ForeignItemFn {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// 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(doc_cfg, doc(cfg(feature = "full")))]
pub struct ForeignItemStatic {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A foreign type in an `extern` block: `type void`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ForeignItemType {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A macro invocation within an extern block.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ForeignItemMacro {
pub attrs: Vec<Attribute>,
pub mac: Macro,
///
/// This type is a [syntax tree enum].
///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
+ /// [syntax tree enum]: Expr#syntax-tree-enums
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub enum TraitItem {
/// An associated constant within the definition of a trait.
Const(TraitItemConst),
/// Tokens within the definition of a trait not interpreted by Syn.
Verbatim(TokenStream),
+ // The following is the only supported idiom for exhaustive matching of
+ // this enum.
+ //
+ // match expr {
+ // TraitItem::Const(e) => {...}
+ // TraitItem::Method(e) => {...}
+ // ...
+ // TraitItem::Verbatim(e) => {...}
+ //
+ // #[cfg(test)]
+ // TraitItem::__TestExhaustive(_) => unimplemented!(),
+ // #[cfg(not(test))]
+ // _ => { /* some sane fallback */ }
+ // }
+ //
+ // This way we fail your tests but don't break your library when adding
+ // a variant. You will be notified by a test failure when a variant is
+ // added, so that you can add code to handle it, but your library will
+ // continue to compile and work for downstream users in the interim.
+ //
+ // Once `deny(reachable)` is available in rustc, TraitItem will be
+ // reimplemented as a non_exhaustive enum.
+ // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237
#[doc(hidden)]
- __Nonexhaustive,
+ __TestExhaustive(crate::private),
}
}
/// An associated constant within the definition of a trait.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct TraitItemConst {
pub attrs: Vec<Attribute>,
pub const_token: Token![const],
/// A trait method within the definition of a trait.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct TraitItemMethod {
pub attrs: Vec<Attribute>,
pub sig: Signature,
/// An associated type within the definition of a trait.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct TraitItemType {
pub attrs: Vec<Attribute>,
pub type_token: Token![type],
/// A macro invocation within the definition of a trait.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct TraitItemMacro {
pub attrs: Vec<Attribute>,
pub mac: Macro,
///
/// This type is a [syntax tree enum].
///
- /// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
- //
- // TODO: change syntax-tree-enum link to an intra rustdoc link, currently
- // blocked on https://github.com/rust-lang/rust/issues/62833
+ /// [syntax tree enum]: Expr#syntax-tree-enums
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub enum ImplItem {
/// An associated constant within an impl block.
Const(ImplItemConst),
/// Tokens within an impl block not interpreted by Syn.
Verbatim(TokenStream),
+ // The following is the only supported idiom for exhaustive matching of
+ // this enum.
+ //
+ // match expr {
+ // ImplItem::Const(e) => {...}
+ // ImplItem::Method(e) => {...}
+ // ...
+ // ImplItem::Verbatim(e) => {...}
+ //
+ // #[cfg(test)]
+ // ImplItem::__TestExhaustive(_) => unimplemented!(),
+ // #[cfg(not(test))]
+ // _ => { /* some sane fallback */ }
+ // }
+ //
+ // This way we fail your tests but don't break your library when adding
+ // a variant. You will be notified by a test failure when a variant is
+ // added, so that you can add code to handle it, but your library will
+ // continue to compile and work for downstream users in the interim.
+ //
+ // Once `deny(reachable)` is available in rustc, ImplItem will be
+ // reimplemented as a non_exhaustive enum.
+ // https://github.com/rust-lang/rust/issues/44109#issuecomment-521781237
#[doc(hidden)]
- __Nonexhaustive,
+ __TestExhaustive(crate::private),
}
}
/// An associated constant within an impl block.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ImplItemConst {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A method within an impl block.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ImplItemMethod {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// An associated type within an impl block.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ImplItemType {
pub attrs: Vec<Attribute>,
pub vis: Visibility,
/// A macro invocation within an impl block.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct ImplItemMacro {
pub attrs: Vec<Attribute>,
pub mac: Macro,
/// initialize(&self)`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct Signature {
pub constness: Option<Token![const]>,
pub asyncness: Option<Token![async]>,
/// 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(doc_cfg, doc(cfg(feature = "full")))]
pub enum FnArg {
/// The `self` argument of an associated method, whether taken by value
/// or by reference.
/// Box<Self>`, are parsed as a `FnArg::Typed`.
///
/// *This type is available only if Syn is built with the `"full"` feature.*
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "full")))]
pub struct Receiver {
pub attrs: Vec<Attribute>,
pub reference: Option<(Token![&], Option<Lifetime>)>,
use std::iter::{self, FromIterator};
crate::custom_keyword!(existential);
+ crate::custom_keyword!(macro_rules);
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for Item {
fn parse(input: ParseStream) -> Result<Self> {
let begin = input.fork();
let lookahead = ahead.lookahead1();
let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
let vis: Visibility = input.parse()?;
- let sig = parse_signature(input)?;
+ let sig: Signature = input.parse()?;
if input.peek(Token![;]) {
input.parse::<Token![;]>()?;
Ok(Item::Verbatim(verbatim::between(begin, input)))
let static_token = input.parse()?;
let mutability = input.parse()?;
let ident = input.parse()?;
- let colon_token = input.parse()?;
- let ty = input.parse()?;
- if input.peek(Token![;]) {
+ if input.peek(Token![=]) {
+ input.parse::<Token![=]>()?;
+ input.parse::<Expr>()?;
input.parse::<Token![;]>()?;
Ok(Item::Verbatim(verbatim::between(begin, input)))
} else {
- Ok(Item::Static(ItemStatic {
- attrs: Vec::new(),
- vis,
- static_token,
- mutability,
- ident,
- colon_token,
- ty,
- eq_token: input.parse()?,
- expr: input.parse()?,
- semi_token: input.parse()?,
- }))
+ let colon_token = input.parse()?;
+ let ty = input.parse()?;
+ if input.peek(Token![;]) {
+ input.parse::<Token![;]>()?;
+ Ok(Item::Verbatim(verbatim::between(begin, input)))
+ } else {
+ Ok(Item::Static(ItemStatic {
+ attrs: Vec::new(),
+ vis,
+ static_token,
+ mutability,
+ ident,
+ colon_token,
+ ty,
+ eq_token: input.parse()?,
+ expr: input.parse()?,
+ semi_token: input.parse()?,
+ }))
+ }
}
} else if lookahead.peek(Token![const]) {
ahead.parse::<Token![const]>()?;
{
input.parse().map(Item::Trait)
} else if lookahead.peek(Token![impl]) {
- let allow_const_impl = true;
- if let Some(item) = parse_impl(input, allow_const_impl)? {
+ let allow_verbatim_impl = true;
+ if let Some(item) = parse_impl(input, allow_verbatim_impl)? {
Ok(Item::Impl(item))
} else {
Ok(Item::Verbatim(verbatim::between(begin, input)))
}
+ } else if lookahead.peek(Token![extern]) {
+ input.parse::<Visibility>()?;
+ input.parse::<Token![unsafe]>()?;
+ input.parse::<ItemForeignMod>()?;
+ Ok(Item::Verbatim(verbatim::between(begin, input)))
+ } else if lookahead.peek(Token![mod]) {
+ input.parse::<Visibility>()?;
+ input.parse::<Token![unsafe]>()?;
+ input.parse::<ItemMod>()?;
+ Ok(Item::Verbatim(verbatim::between(begin, input)))
} else {
Err(lookahead.error())
}
} else if lookahead.peek(Token![impl])
|| lookahead.peek(Token![default]) && !ahead.peek2(Token![!])
{
- let allow_const_impl = true;
- if let Some(item) = parse_impl(input, allow_const_impl)? {
+ let allow_verbatim_impl = true;
+ if let Some(item) = parse_impl(input, allow_verbatim_impl)? {
Ok(Item::Impl(item))
} else {
Ok(Item::Verbatim(verbatim::between(begin, input)))
|| lookahead.peek(Token![::]))
{
input.parse().map(Item::Macro)
+ } else if ahead.peek(macro_rules) {
+ input.advance_to(&ahead);
+ input.parse::<ItemMacro>()?;
+ Ok(Item::Verbatim(verbatim::between(begin, input)))
} else {
Err(lookahead.error())
}?;
let mut bounds = Punctuated::new();
if colon_token.is_some() {
loop {
- bounds.push_value(input.parse::<TypeParamBound>()?);
if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
break;
}
- bounds.push_punct(input.parse::<Token![+]>()?);
+ bounds.push_value(input.parse::<TypeParamBound>()?);
if input.peek(Token![where]) || input.peek(Token![=]) || input.peek(Token![;]) {
break;
}
+ bounds.push_punct(input.parse::<Token![+]>()?);
}
}
generics.where_clause = input.parse()?;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemMacro {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemMacro2 {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemExternCrate {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ItemExternCrate {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemUse {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ItemUse {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for UseTree {
fn parse(input: ParseStream) -> Result<UseTree> {
let lookahead = input.lookahead1();
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemStatic {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ItemStatic {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemConst {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ItemConst {
&& fork.peek(Token![fn])
}
- fn parse_signature(input: ParseStream) -> Result<Signature> {
- let constness: Option<Token![const]> = input.parse()?;
- let asyncness: Option<Token![async]> = input.parse()?;
- let unsafety: Option<Token![unsafe]> = input.parse()?;
- let abi: Option<Abi> = input.parse()?;
- let fn_token: Token![fn] = input.parse()?;
- let ident: Ident = input.parse()?;
- let generics: Generics = input.parse()?;
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
+ impl Parse for Signature {
+ fn parse(input: ParseStream) -> Result<Self> {
+ let constness: Option<Token![const]> = input.parse()?;
+ let asyncness: Option<Token![async]> = input.parse()?;
+ let unsafety: Option<Token![unsafe]> = input.parse()?;
+ let abi: Option<Abi> = input.parse()?;
+ let fn_token: Token![fn] = input.parse()?;
+ let ident: Ident = input.parse()?;
+ let mut generics: Generics = input.parse()?;
- let content;
- let paren_token = parenthesized!(content in input);
- let mut inputs = parse_fn_args(&content)?;
- let variadic = pop_variadic(&mut inputs);
+ let content;
+ let paren_token = parenthesized!(content in input);
+ let mut inputs = parse_fn_args(&content)?;
+ let variadic = pop_variadic(&mut inputs);
- let output: ReturnType = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
+ let output: ReturnType = input.parse()?;
+ generics.where_clause = input.parse()?;
- Ok(Signature {
- constness,
- asyncness,
- unsafety,
- abi,
- fn_token,
- ident,
- paren_token,
- inputs,
- output,
- variadic,
- generics: Generics {
- where_clause,
- ..generics
- },
- })
+ Ok(Signature {
+ constness,
+ asyncness,
+ unsafety,
+ abi,
+ fn_token,
+ ident,
+ generics,
+ paren_token,
+ inputs,
+ variadic,
+ output,
+ })
+ }
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemFn {
fn parse(input: ParseStream) -> Result<Self> {
let outer_attrs = input.call(Attribute::parse_outer)?;
let vis: Visibility = input.parse()?;
- let sig = parse_signature(input)?;
+ let sig: Signature = input.parse()?;
parse_rest_of_fn(input, outer_attrs, vis, sig)
}
}
fn parse_rest_of_fn(
input: ParseStream,
- outer_attrs: Vec<Attribute>,
+ mut attrs: Vec<Attribute>,
vis: Visibility,
sig: Signature,
) -> Result<ItemFn> {
let content;
let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
+ attr::parsing::parse_inner(&content, &mut attrs)?;
let stmts = content.call(Block::parse_within)?;
Ok(ItemFn {
- attrs: private::attrs(outer_attrs, inner_attrs),
+ attrs,
vis,
sig,
block: Box::new(Block { brace_token, stmts }),
})
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for FnArg {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for Receiver {
fn parse(input: ParseStream) -> Result<Self> {
Ok(Receiver {
})
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemMod {
fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
+ let mut attrs = input.call(Attribute::parse_outer)?;
let vis: Visibility = input.parse()?;
let mod_token: Token![mod] = input.parse()?;
let ident: Ident = input.parse()?;
let lookahead = input.lookahead1();
if lookahead.peek(Token![;]) {
Ok(ItemMod {
- attrs: outer_attrs,
+ attrs,
vis,
mod_token,
ident,
} else if lookahead.peek(token::Brace) {
let content;
let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
+ attr::parsing::parse_inner(&content, &mut attrs)?;
let mut items = Vec::new();
while !content.is_empty() {
}
Ok(ItemMod {
- attrs: private::attrs(outer_attrs, inner_attrs),
+ attrs,
vis,
mod_token,
ident,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemForeignMod {
fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
+ let mut attrs = input.call(Attribute::parse_outer)?;
let abi: Abi = input.parse()?;
let content;
let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
+ attr::parsing::parse_inner(&content, &mut attrs)?;
let mut items = Vec::new();
while !content.is_empty() {
items.push(content.parse()?);
}
Ok(ItemForeignMod {
- attrs: private::attrs(outer_attrs, inner_attrs),
+ attrs,
abi,
brace_token,
items,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ForeignItem {
fn parse(input: ParseStream) -> Result<Self> {
let begin = input.fork();
let lookahead = ahead.lookahead1();
let mut item = if lookahead.peek(Token![fn]) || peek_signature(&ahead) {
let vis: Visibility = input.parse()?;
- let sig = parse_signature(input)?;
+ let sig: Signature = input.parse()?;
if input.peek(token::Brace) {
let content;
braced!(content in input);
ForeignItem::Type(item) => &mut item.attrs,
ForeignItem::Macro(item) => &mut item.attrs,
ForeignItem::Verbatim(_) => return Ok(item),
- ForeignItem::__Nonexhaustive => unreachable!(),
+
+ #[cfg(test)]
+ ForeignItem::__TestExhaustive(_) => unimplemented!(),
+ #[cfg(not(test))]
+ _ => unreachable!(),
};
attrs.extend(item_attrs.drain(..));
*item_attrs = attrs;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ForeignItemFn {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
let vis: Visibility = input.parse()?;
- let sig = parse_signature(input)?;
+ let sig: Signature = input.parse()?;
let semi_token: Token![;] = input.parse()?;
Ok(ForeignItemFn {
attrs,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ForeignItemStatic {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ForeignItemStatic {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ForeignItemType {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ForeignItemType {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ForeignItemMacro {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemType {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ItemType {
Ok(tokens)
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemStruct {
fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
+ let mut attrs = input.call(Attribute::parse_outer)?;
let vis = input.parse::<Visibility>()?;
let struct_token = input.parse::<Token![struct]>()?;
let ident = input.parse::<Ident>()?;
let generics = input.parse::<Generics>()?;
- let (where_clause, fields, semi_token) = derive::parsing::data_struct(input)?;
+ let (where_clause, fields, semi_token) =
+ derive::parsing::data_struct(input, &mut attrs)?;
Ok(ItemStruct {
attrs,
vis,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemEnum {
fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
+ let mut attrs = input.call(Attribute::parse_outer)?;
let vis = input.parse::<Visibility>()?;
let enum_token = input.parse::<Token![enum]>()?;
let ident = input.parse::<Ident>()?;
let generics = input.parse::<Generics>()?;
- let (where_clause, brace_token, variants) = derive::parsing::data_enum(input)?;
+ let (where_clause, brace_token, variants) =
+ derive::parsing::data_enum(input, &mut attrs)?;
Ok(ItemEnum {
attrs,
vis,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemUnion {
fn parse(input: ParseStream) -> Result<Self> {
- let attrs = input.call(Attribute::parse_outer)?;
+ let mut attrs = input.call(Attribute::parse_outer)?;
let vis = input.parse::<Visibility>()?;
let union_token = input.parse::<Token![union]>()?;
let ident = input.parse::<Ident>()?;
let generics = input.parse::<Generics>()?;
- let (where_clause, fields) = derive::parsing::data_union(input)?;
+ let (where_clause, fields) = derive::parsing::data_union(input, &mut attrs)?;
Ok(ItemUnion {
attrs,
vis,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemTrait {
fn parse(input: ParseStream) -> Result<Self> {
let outer_attrs = input.call(Attribute::parse_outer)?;
fn parse_rest_of_trait(
input: ParseStream,
- outer_attrs: Vec<Attribute>,
+ mut attrs: Vec<Attribute>,
vis: Visibility,
unsafety: Option<Token![unsafe]>,
auto_token: Option<Token![auto]>,
let mut supertraits = Punctuated::new();
if colon_token.is_some() {
loop {
- supertraits.push_value(input.parse()?);
if input.peek(Token![where]) || input.peek(token::Brace) {
break;
}
- supertraits.push_punct(input.parse()?);
+ supertraits.push_value(input.parse()?);
if input.peek(Token![where]) || input.peek(token::Brace) {
break;
}
+ supertraits.push_punct(input.parse()?);
}
}
let content;
let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
+ attr::parsing::parse_inner(&content, &mut attrs)?;
let mut items = Vec::new();
while !content.is_empty() {
items.push(content.parse()?);
}
Ok(ItemTrait {
- attrs: private::attrs(outer_attrs, inner_attrs),
+ attrs,
vis,
unsafety,
auto_token,
})
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemTraitAlias {
fn parse(input: ParseStream) -> Result<Self> {
let (attrs, vis, trait_token, ident, generics) = parse_start_of_trait_alias(input)?;
})
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for TraitItem {
fn parse(input: ParseStream) -> Result<Self> {
let begin = input.fork();
TraitItem::Method(item) => &mut item.attrs,
TraitItem::Type(item) => &mut item.attrs,
TraitItem::Macro(item) => &mut item.attrs,
- TraitItem::Verbatim(_) | TraitItem::__Nonexhaustive => unreachable!(),
+ TraitItem::Verbatim(_) => unreachable!(),
+
+ #[cfg(test)]
+ TraitItem::__TestExhaustive(_) => unimplemented!(),
+ #[cfg(not(test))]
+ _ => unreachable!(),
};
attrs.extend(item_attrs.drain(..));
*item_attrs = attrs;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for TraitItemConst {
fn parse(input: ParseStream) -> Result<Self> {
Ok(TraitItemConst {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for TraitItemMethod {
fn parse(input: ParseStream) -> Result<Self> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
- let sig = parse_signature(input)?;
+ let mut attrs = input.call(Attribute::parse_outer)?;
+ let sig: Signature = input.parse()?;
let lookahead = input.lookahead1();
- let (brace_token, inner_attrs, stmts, semi_token) = if lookahead.peek(token::Brace) {
+ let (brace_token, stmts, semi_token) = if lookahead.peek(token::Brace) {
let content;
let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
+ attr::parsing::parse_inner(&content, &mut attrs)?;
let stmts = content.call(Block::parse_within)?;
- (Some(brace_token), inner_attrs, stmts, None)
+ (Some(brace_token), stmts, None)
} else if lookahead.peek(Token![;]) {
let semi_token: Token![;] = input.parse()?;
- (None, Vec::new(), Vec::new(), Some(semi_token))
+ (None, Vec::new(), Some(semi_token))
} else {
return Err(lookahead.error());
};
Ok(TraitItemMethod {
- attrs: private::attrs(outer_attrs, inner_attrs),
+ attrs,
sig,
default: brace_token.map(|brace_token| Block { brace_token, stmts }),
semi_token,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for TraitItemType {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for TraitItemMacro {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ItemImpl {
fn parse(input: ParseStream) -> Result<Self> {
- let allow_const_impl = false;
- parse_impl(input, allow_const_impl).map(Option::unwrap)
+ let allow_verbatim_impl = false;
+ parse_impl(input, allow_verbatim_impl).map(Option::unwrap)
}
}
- fn parse_impl(input: ParseStream, allow_const_impl: bool) -> Result<Option<ItemImpl>> {
- let outer_attrs = input.call(Attribute::parse_outer)?;
+ fn parse_impl(input: ParseStream, allow_verbatim_impl: bool) -> Result<Option<ItemImpl>> {
+ let mut attrs = input.call(Attribute::parse_outer)?;
+ let has_visibility = allow_verbatim_impl && input.parse::<Visibility>()?.is_some();
let defaultness: Option<Token![default]> = input.parse()?;
let unsafety: Option<Token![unsafe]> = input.parse()?;
let impl_token: Token![impl] = input.parse()?;
|| (input.peek2(Ident) || input.peek2(Lifetime))
&& (input.peek3(Token![:])
|| input.peek3(Token![,])
- || input.peek3(Token![>]))
+ || input.peek3(Token![>])
+ || input.peek3(Token![=]))
|| input.peek2(Token![const]));
- let generics: Generics = if has_generics {
+ let mut generics: Generics = if has_generics {
input.parse()?
} else {
Generics::default()
};
- let is_const_impl = allow_const_impl
+ let is_const_impl = allow_verbatim_impl
&& (input.peek(Token![const]) || input.peek(Token![?]) && input.peek2(Token![const]));
if is_const_impl {
input.parse::<Option<Token![?]>>()?;
input.parse::<Token![const]>()?;
}
- let trait_ = (|| -> Option<_> {
- let ahead = input.fork();
- let polarity: Option<Token![!]> = ahead.parse().ok()?;
- let mut path: Path = ahead.parse().ok()?;
- if path.segments.last().unwrap().arguments.is_empty() && ahead.peek(token::Paren) {
- let parenthesized = PathArguments::Parenthesized(ahead.parse().ok()?);
- path.segments.last_mut().unwrap().arguments = parenthesized;
+ let begin = input.fork();
+ let polarity = if input.peek(Token![!]) && !input.peek2(token::Brace) {
+ Some(input.parse::<Token![!]>()?)
+ } else {
+ None
+ };
+
+ #[cfg(not(feature = "printing"))]
+ let first_ty_span = input.span();
+ let mut first_ty: Type = input.parse()?;
+ let self_ty: Type;
+ let trait_;
+
+ let is_impl_for = input.peek(Token![for]);
+ if is_impl_for {
+ let for_token: Token![for] = input.parse()?;
+ let mut first_ty_ref = &first_ty;
+ while let Type::Group(ty) = first_ty_ref {
+ first_ty_ref = &ty.elem;
}
- let for_token: Token![for] = ahead.parse().ok()?;
- input.advance_to(&ahead);
- Some((polarity, path, for_token))
- })();
+ if let Type::Path(_) = first_ty_ref {
+ while let Type::Group(ty) = first_ty {
+ first_ty = *ty.elem;
+ }
+ if let Type::Path(TypePath { qself: None, path }) = first_ty {
+ trait_ = Some((polarity, path, for_token));
+ } else {
+ unreachable!()
+ }
+ } else if !allow_verbatim_impl {
+ #[cfg(feature = "printing")]
+ return Err(Error::new_spanned(first_ty_ref, "expected trait path"));
+ #[cfg(not(feature = "printing"))]
+ return Err(Error::new(first_ty_span, "expected trait path"));
+ } else {
+ trait_ = None;
+ }
+ self_ty = input.parse()?;
+ } else {
+ trait_ = None;
+ self_ty = if polarity.is_none() {
+ first_ty
+ } else {
+ Type::Verbatim(verbatim::between(begin, input))
+ };
+ }
- let self_ty: Type = input.parse()?;
- let where_clause: Option<WhereClause> = input.parse()?;
+ generics.where_clause = input.parse()?;
let content;
let brace_token = braced!(content in input);
- let inner_attrs = content.call(Attribute::parse_inner)?;
+ attr::parsing::parse_inner(&content, &mut attrs)?;
let mut items = Vec::new();
while !content.is_empty() {
items.push(content.parse()?);
}
- if is_const_impl {
+ if has_visibility || is_const_impl || is_impl_for && trait_.is_none() {
Ok(None)
} else {
Ok(Some(ItemImpl {
- attrs: private::attrs(outer_attrs, inner_attrs),
+ attrs,
defaultness,
unsafety,
impl_token,
- generics: Generics {
- where_clause,
- ..generics
- },
+ generics,
trait_,
self_ty: Box::new(self_ty),
brace_token,
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ImplItem {
fn parse(input: ParseStream) -> Result<Self> {
let begin = input.fork();
ImplItem::Type(item) => &mut item.attrs,
ImplItem::Macro(item) => &mut item.attrs,
ImplItem::Verbatim(_) => return Ok(item),
- ImplItem::__Nonexhaustive => unreachable!(),
+
+ #[cfg(test)]
+ ImplItem::__TestExhaustive(_) => unimplemented!(),
+ #[cfg(not(test))]
+ _ => unreachable!(),
};
attrs.extend(item_attrs.drain(..));
*item_attrs = attrs;
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ImplItemConst {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ImplItemConst {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ImplItemMethod {
fn parse(input: ParseStream) -> Result<Self> {
let mut attrs = input.call(Attribute::parse_outer)?;
let vis: Visibility = input.parse()?;
let defaultness: Option<Token![default]> = input.parse()?;
- let sig = parse_signature(input)?;
+ let sig: Signature = input.parse()?;
let block = if let Some(semi) = input.parse::<Option<Token![;]>>()? {
// Accept methods without a body in an impl block because
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ImplItemType {
fn parse(input: ParseStream) -> Result<Self> {
Ok(ImplItemType {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "parsing")))]
impl Parse for ImplItemMacro {
fn parse(input: ParseStream) -> Result<Self> {
let attrs = input.call(Attribute::parse_outer)?;
use proc_macro2::TokenStream;
use quote::{ToTokens, TokenStreamExt};
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemExternCrate {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemUse {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemStatic {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemConst {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemFn {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemMod {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemForeignMod {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemType {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemEnum {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemStruct {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemUnion {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemTrait {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
self.generics.where_clause.to_tokens(tokens);
self.brace_token.surround(tokens, |tokens| {
+ tokens.append_all(self.attrs.inner());
tokens.append_all(&self.items);
});
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemTraitAlias {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemImpl {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemMacro {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ItemMacro2 {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for UsePath {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.ident.to_tokens(tokens);
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for UseName {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.ident.to_tokens(tokens);
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for UseRename {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.ident.to_tokens(tokens);
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for UseGlob {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.star_token.to_tokens(tokens);
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for UseGroup {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.brace_token.surround(tokens, |tokens| {
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for TraitItemConst {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for TraitItemMethod {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for TraitItemType {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for TraitItemMacro {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ImplItemConst {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ImplItemMethod {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ImplItemType {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ImplItemMacro {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ForeignItemFn {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ForeignItemStatic {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ForeignItemType {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for ForeignItemMacro {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for Signature {
fn to_tokens(&self, tokens: &mut TokenStream) {
self.constness.to_tokens(tokens);
}
}
+ #[cfg_attr(doc_cfg, doc(cfg(feature = "printing")))]
impl ToTokens for Receiver {
fn to_tokens(&self, tokens: &mut TokenStream) {
tokens.append_all(self.attrs.outer());