mirror of
https://gitee.com/openharmony/third_party_rust_syn
synced 2024-11-23 16:00:10 +00:00
Document what feature everything requires
This commit is contained in:
parent
614a01433b
commit
461d98ee7c
@ -1026,6 +1026,8 @@ use gen::helper::fold::*;
|
||||
/// See the [module documentation] for details.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This trait is available if Syn is built with the `\"fold\"` feature.*
|
||||
pub trait Fold {{
|
||||
{fold_trait}
|
||||
}}
|
||||
@ -1086,6 +1088,8 @@ use gen::helper::visit::*;
|
||||
/// See the [module documentation] for details.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This trait is available if Syn is built with the `\"visit\"` feature.*
|
||||
pub trait Visit<'ast> {{
|
||||
{visit_trait}
|
||||
}}
|
||||
@ -1122,6 +1126,8 @@ use gen::helper::visit_mut::*;
|
||||
/// See the [module documentation] for details.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This trait is available if Syn is built with the `\"visit-mut\"` feature.*
|
||||
pub trait VisitMut {{
|
||||
{visit_mut_trait}
|
||||
}}
|
||||
|
18
src/attr.rs
18
src/attr.rs
@ -21,6 +21,9 @@ use tt::TokenStreamHelper;
|
||||
ast_struct! {
|
||||
/// An attribute like `#[repr(transparent)]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax
|
||||
///
|
||||
/// Rust has six types of attributes.
|
||||
@ -225,6 +228,9 @@ ast_enum! {
|
||||
/// Distinguishes between attributes that decorate an item and attributes
|
||||
/// that are contained within an item.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Outer attributes
|
||||
///
|
||||
/// - `#[repr(transparent)]`
|
||||
@ -246,6 +252,9 @@ ast_enum! {
|
||||
ast_enum_of_structs! {
|
||||
/// Content of a compile-time structured attribute.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// ## Word
|
||||
///
|
||||
/// A meta word is like the `test` in `#[test]`.
|
||||
@ -267,12 +276,18 @@ ast_enum_of_structs! {
|
||||
pub enum Meta {
|
||||
pub Word(Ident),
|
||||
/// A structured list within an attribute, like `derive(Copy, Clone)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub List(MetaList {
|
||||
pub ident: Ident,
|
||||
pub paren_token: token::Paren,
|
||||
pub nested: Punctuated<NestedMeta, Token![,]>,
|
||||
}),
|
||||
/// A name-value pair within an attribute, like `feature = "nightly"`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub NameValue(MetaNameValue {
|
||||
pub ident: Ident,
|
||||
pub eq_token: Token![=],
|
||||
@ -297,6 +312,9 @@ impl Meta {
|
||||
|
||||
ast_enum_of_structs! {
|
||||
/// Element of a compile-time attribute list.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum NestedMeta {
|
||||
/// A structured meta item, like the `Copy` in `#[derive(Copy)]` which
|
||||
/// would be a nested `Meta::Word`.
|
||||
|
@ -14,6 +14,8 @@
|
||||
//!
|
||||
//! [`Synom`]: ../synom/trait.Synom.html
|
||||
//!
|
||||
//! *This module is available if Syn is built with the `"parsing"` feature.*
|
||||
//!
|
||||
//! # Example
|
||||
//!
|
||||
//! This example shows a basic token parser for parsing a token stream without
|
||||
@ -154,6 +156,8 @@ enum Entry {
|
||||
/// See the [module documentation] for an example of `TokenBuffer` in action.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"parsing"` feature.*
|
||||
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
|
||||
@ -246,6 +250,8 @@ impl TokenBuffer {
|
||||
/// See the [module documentation] for an example of a `Cursor` in action.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"parsing"` feature.*
|
||||
#[derive(Copy, Clone, Eq, PartialEq)]
|
||||
pub struct Cursor<'a> {
|
||||
/// The current entry which the `Cursor` is pointing at.
|
||||
|
27
src/data.rs
27
src/data.rs
@ -11,6 +11,9 @@ use punctuated::Punctuated;
|
||||
|
||||
ast_struct! {
|
||||
/// An enum variant.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct Variant {
|
||||
/// Attributes tagged on the variant.
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -29,6 +32,9 @@ ast_struct! {
|
||||
ast_enum_of_structs! {
|
||||
/// Data stored within an enum variant or struct.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -37,12 +43,18 @@ ast_enum_of_structs! {
|
||||
pub enum Fields {
|
||||
/// Named fields of a struct or struct variant such as `Point { x: f64,
|
||||
/// y: f64 }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Named(FieldsNamed {
|
||||
pub brace_token: token::Brace,
|
||||
pub named: Punctuated<Field, Token![,]>,
|
||||
}),
|
||||
|
||||
/// Unnamed fields of a tuple struct or tuple variant such as `Some(T)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Unnamed(FieldsUnnamed {
|
||||
pub paren_token: token::Paren,
|
||||
pub unnamed: Punctuated<Field, Token![,]>,
|
||||
@ -55,6 +67,9 @@ ast_enum_of_structs! {
|
||||
|
||||
ast_struct! {
|
||||
/// A field of a struct or enum variant.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct Field {
|
||||
/// Attributes tagged on the field.
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -78,6 +93,9 @@ ast_enum_of_structs! {
|
||||
/// The visibility level of an item: inherited or `pub` or
|
||||
/// `pub(restricted)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -85,11 +103,17 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum Visibility {
|
||||
/// A public visibility level: `pub`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Public(VisPublic {
|
||||
pub pub_token: Token![pub],
|
||||
}),
|
||||
|
||||
/// A crate-level visibility: `pub(crate)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Crate(VisCrate {
|
||||
pub pub_token: Token![pub],
|
||||
pub paren_token: token::Paren,
|
||||
@ -98,6 +122,9 @@ ast_enum_of_structs! {
|
||||
|
||||
/// A visibility level restricted to some path: `pub(self)` or
|
||||
/// `pub(super)` or `pub(in some::module)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Restricted(VisRestricted {
|
||||
pub pub_token: Token![pub],
|
||||
pub paren_token: token::Paren,
|
||||
|
@ -11,6 +11,8 @@ use punctuated::Punctuated;
|
||||
|
||||
ast_struct! {
|
||||
/// Data structure sent to a `proc_macro_derive` macro.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` feature.*
|
||||
pub struct DeriveInput {
|
||||
/// Attributes tagged on the whole struct or enum.
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -32,6 +34,8 @@ ast_struct! {
|
||||
ast_enum_of_structs! {
|
||||
/// The storage of a struct, enum or union data structure.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -39,6 +43,9 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum Data {
|
||||
/// A struct input to a `proc_macro_derive` macro.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"`
|
||||
/// feature.*
|
||||
pub Struct(DataStruct {
|
||||
pub struct_token: Token![struct],
|
||||
pub fields: Fields,
|
||||
@ -46,6 +53,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// An enum input to a `proc_macro_derive` macro.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"`
|
||||
/// feature.*
|
||||
pub Enum(DataEnum {
|
||||
pub enum_token: Token![enum],
|
||||
pub brace_token: token::Brace,
|
||||
@ -53,6 +63,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A tagged union input to a `proc_macro_derive` macro.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"`
|
||||
/// feature.*
|
||||
pub Union(DataUnion {
|
||||
pub union_token: Token![union],
|
||||
pub fields: FieldsNamed,
|
||||
|
@ -15,6 +15,8 @@ use std::fmt::{self, Display};
|
||||
/// Refer to the [module documentation] for details about parsing in Syn.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"parsing"` feature.*
|
||||
pub type PResult<'a, O> = Result<(O, Cursor<'a>), ParseError>;
|
||||
|
||||
/// An error with a default error message.
|
||||
@ -29,6 +31,8 @@ pub fn parse_error<O>() -> PResult<'static, O> {
|
||||
/// Refer to the [module documentation] for details about parsing in Syn.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"parsing"` feature.*
|
||||
#[derive(Debug)]
|
||||
pub struct ParseError(Option<String>);
|
||||
|
||||
|
145
src/expr.rs
145
src/expr.rs
@ -19,6 +19,9 @@ use std::mem;
|
||||
ast_enum_of_structs! {
|
||||
/// A Rust expression.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax tree enums
|
||||
///
|
||||
/// This type is a syntax tree enum. In Syn this and other syntax tree enums
|
||||
@ -102,6 +105,8 @@ ast_enum_of_structs! {
|
||||
/// `receiver.receiver` or `pat.pat` or `cond.cond`.
|
||||
pub enum Expr {
|
||||
/// A box expression: `box f`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Box(ExprBox #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub box_token: Token![box],
|
||||
@ -109,6 +114,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A placement expression: `place <- value`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub InPlace(ExprInPlace #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub place: Box<Expr>,
|
||||
@ -117,6 +124,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A slice literal expression: `[a, b, c, d]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Array(ExprArray #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub bracket_token: token::Bracket,
|
||||
@ -124,6 +133,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A function call expression: `invoke(a, b)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Call(ExprCall {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub func: Box<Expr>,
|
||||
@ -132,6 +144,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A method call expression: `x.foo::<T>(a, b)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub MethodCall(ExprMethodCall #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub receiver: Box<Expr>,
|
||||
@ -143,6 +157,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A tuple expression: `(a, b, c, d)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Tuple(ExprTuple #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub paren_token: token::Paren,
|
||||
@ -150,6 +166,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A binary operation: `a + b`, `a * b`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Binary(ExprBinary {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub left: Box<Expr>,
|
||||
@ -158,6 +177,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A unary operation: `!x`, `*x`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Unary(ExprUnary {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub op: UnOp,
|
||||
@ -165,12 +187,18 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A literal in place of an expression: `1`, `"foo"`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Lit(ExprLit {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub lit: Lit,
|
||||
}),
|
||||
|
||||
/// A cast expression: `foo as f64`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Cast(ExprCast {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub expr: Box<Expr>,
|
||||
@ -179,6 +207,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A type ascription expression: `foo: f64`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Type(ExprType #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub expr: Box<Expr>,
|
||||
@ -191,6 +221,8 @@ ast_enum_of_structs! {
|
||||
///
|
||||
/// The `else` branch expression may only be an `If`, `IfLet`, or
|
||||
/// `Block` expression, not any of the other types of expression.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub If(ExprIf #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub if_token: Token![if],
|
||||
@ -204,6 +236,8 @@ ast_enum_of_structs! {
|
||||
///
|
||||
/// The `else` branch expression may only be an `If`, `IfLet`, or
|
||||
/// `Block` expression, not any of the other types of expression.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub IfLet(ExprIfLet #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub if_token: Token![if],
|
||||
@ -216,6 +250,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A while loop: `while expr { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub While(ExprWhile #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub label: Option<Label>,
|
||||
@ -225,6 +261,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A while-let loop: `while let pat = expr { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub WhileLet(ExprWhileLet #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub label: Option<Label>,
|
||||
@ -237,6 +275,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A for loop: `for pat in expr { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub ForLoop(ExprForLoop #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub label: Option<Label>,
|
||||
@ -248,6 +288,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// Conditionless loop: `loop { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Loop(ExprLoop #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub label: Option<Label>,
|
||||
@ -256,6 +298,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A `match` expression: `match n { Some(n) => {}, None => {} }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Match(ExprMatch #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub match_token: Token![match],
|
||||
@ -265,6 +309,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A closure expression: `|a, b| a + b`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Closure(ExprClosure #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub capture: Option<Token![move]>,
|
||||
@ -276,6 +322,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// An unsafe block: `unsafe { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Unsafe(ExprUnsafe #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub unsafe_token: Token![unsafe],
|
||||
@ -283,12 +331,16 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A blocked scope: `{ ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Block(ExprBlock #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub block: Block,
|
||||
}),
|
||||
|
||||
/// An assignment expression: `a = compute()`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Assign(ExprAssign #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub left: Box<Expr>,
|
||||
@ -297,6 +349,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A compound assignment expression: `counter += 1`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub AssignOp(ExprAssignOp #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub left: Box<Expr>,
|
||||
@ -306,6 +360,8 @@ ast_enum_of_structs! {
|
||||
|
||||
/// Access of a named struct field (`obj.k`) or unnamed tuple struct
|
||||
/// field (`obj.0`).
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Field(ExprField #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub base: Box<Expr>,
|
||||
@ -314,6 +370,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A square bracketed indexing expression: `vector[2]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Index(ExprIndex {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub expr: Box<Expr>,
|
||||
@ -322,6 +381,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A range expression: `1..2`, `1..`, `..2`, `1..=2`, `..=2`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Range(ExprRange #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub from: Option<Box<Expr>>,
|
||||
@ -333,6 +394,9 @@ ast_enum_of_structs! {
|
||||
/// parameters and a qualified self-type.
|
||||
///
|
||||
/// A plain identifier like `x` is a path of length 1.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Path(ExprPath {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub qself: Option<QSelf>,
|
||||
@ -340,6 +404,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A referencing operation: `&a` or `&mut a`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub AddrOf(ExprAddrOf #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub and_token: Token![&],
|
||||
@ -349,6 +415,8 @@ ast_enum_of_structs! {
|
||||
|
||||
/// A `break`, with an optional label to break and an optional
|
||||
/// expression.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Break(ExprBreak #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub break_token: Token![break],
|
||||
@ -357,6 +425,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A `continue`, with an optional label.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Continue(ExprContinue #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub continue_token: Token![continue],
|
||||
@ -364,6 +434,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A `return`, with an optional value to be returned.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Return(ExprReturn #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub return_token: Token![return],
|
||||
@ -371,6 +443,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A macro invocation expression: `format!("{}", q)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Macro(ExprMacro #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub mac: Macro,
|
||||
@ -380,6 +454,8 @@ ast_enum_of_structs! {
|
||||
///
|
||||
/// The `rest` provides the value of the remaining fields as in `S { a:
|
||||
/// 1, b: 1, ..rest }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Struct(ExprStruct #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub path: Path,
|
||||
@ -390,6 +466,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// An array literal constructed from one repeated element: `[0u8; N]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Repeat(ExprRepeat #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub bracket_token: token::Bracket,
|
||||
@ -399,6 +477,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A parenthesized expression: `(a + b)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Paren(ExprParen #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub paren_token: token::Paren,
|
||||
@ -410,6 +490,8 @@ ast_enum_of_structs! {
|
||||
/// 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 if Syn is built with the `"full"` feature.*
|
||||
pub Group(ExprGroup #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub group_token: token::Group,
|
||||
@ -417,6 +499,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A try-expression: `expr?`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Try(ExprTry #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub expr: Box<Expr>,
|
||||
@ -424,6 +508,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A catch expression: `do catch { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Catch(ExprCatch #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub do_token: Token![do],
|
||||
@ -432,6 +518,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A yield expression: `yield expr`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Yield(ExprYield #full {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub yield_token: Token![yield],
|
||||
@ -439,6 +527,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// Tokens in expression position not interpreted by Syn.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Verbatim(ExprVerbatim #manual_extra_traits {
|
||||
pub tts: TokenStream,
|
||||
}),
|
||||
@ -521,6 +612,9 @@ impl Expr {
|
||||
ast_enum! {
|
||||
/// A struct or tuple struct field accessed in a struct literal or field
|
||||
/// expression.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum Member {
|
||||
/// A named field like `self.x`.
|
||||
Named(Ident),
|
||||
@ -531,6 +625,9 @@ ast_enum! {
|
||||
|
||||
ast_struct! {
|
||||
/// The index of an unnamed tuple struct field.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct Index #manual_extra_traits {
|
||||
pub index: u32,
|
||||
pub span: Span,
|
||||
@ -568,6 +665,8 @@ impl Hash for Index {
|
||||
ast_struct! {
|
||||
/// The `::<>` explicit type parameters passed to a method call:
|
||||
/// `parse::<u64>()`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct MethodTurbofish {
|
||||
pub colon2_token: Token![::],
|
||||
pub lt_token: Token![<],
|
||||
@ -579,6 +678,8 @@ ast_struct! {
|
||||
#[cfg(feature = "full")]
|
||||
ast_enum! {
|
||||
/// An individual generic argument to a method, like `T`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub enum GenericMethodArgument {
|
||||
/// A type argument.
|
||||
Type(Type),
|
||||
@ -593,6 +694,8 @@ ast_enum! {
|
||||
#[cfg(feature = "full")]
|
||||
ast_struct! {
|
||||
/// A field-value pair in a struct literal.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct FieldValue {
|
||||
/// Attributes tagged on the field.
|
||||
pub attrs: Vec<Attribute>,
|
||||
@ -612,6 +715,8 @@ ast_struct! {
|
||||
#[cfg(feature = "full")]
|
||||
ast_struct! {
|
||||
/// A lifetime labeling a `for`, `while`, or `loop`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct Label {
|
||||
pub name: Lifetime,
|
||||
pub colon_token: Token![:],
|
||||
@ -621,6 +726,8 @@ ast_struct! {
|
||||
#[cfg(feature = "full")]
|
||||
ast_struct! {
|
||||
/// A braced block containing Rust statements.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct Block {
|
||||
pub brace_token: token::Brace,
|
||||
/// Statements in a block
|
||||
@ -631,6 +738,8 @@ ast_struct! {
|
||||
#[cfg(feature = "full")]
|
||||
ast_enum! {
|
||||
/// A statement, usually ending in a semicolon.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub enum Stmt {
|
||||
/// A local (let) binding.
|
||||
Local(Local),
|
||||
@ -649,6 +758,8 @@ ast_enum! {
|
||||
#[cfg(feature = "full")]
|
||||
ast_struct! {
|
||||
/// A local `let` binding: `let x: u64 = s.parse()?`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct Local {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub let_token: Token![let],
|
||||
@ -664,6 +775,8 @@ ast_enum_of_structs! {
|
||||
/// A pattern in a local binding, function signature, match expression, or
|
||||
/// various other places.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -674,11 +787,15 @@ ast_enum_of_structs! {
|
||||
#[cfg_attr(feature = "cargo-clippy", allow(enum_variant_names))]
|
||||
pub enum Pat {
|
||||
/// A pattern that matches any value: `_`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Wild(PatWild {
|
||||
pub underscore_token: Token![_],
|
||||
}),
|
||||
|
||||
/// A pattern that binds a new variable: `ref mut binding @ SUBPATTERN`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Ident(PatIdent {
|
||||
pub by_ref: Option<Token![ref]>,
|
||||
pub mutability: Option<Token![mut]>,
|
||||
@ -687,6 +804,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A struct or struct variant pattern: `Variant { x, y, .. }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Struct(PatStruct {
|
||||
pub path: Path,
|
||||
pub brace_token: token::Brace,
|
||||
@ -695,6 +814,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A tuple struct or tuple variant pattern: `Variant(x, y, .., z)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub TupleStruct(PatTupleStruct {
|
||||
pub path: Path,
|
||||
pub pat: PatTuple,
|
||||
@ -707,12 +828,16 @@ ast_enum_of_structs! {
|
||||
/// constants or associated constants. Quailfied path patterns like
|
||||
/// `<A>::B::C` and `<A as Trait>::B::C` can only legally refer to
|
||||
/// associated constants.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Path(PatPath {
|
||||
pub qself: Option<QSelf>,
|
||||
pub path: Path,
|
||||
}),
|
||||
|
||||
/// A tuple pattern: `(a, b)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Tuple(PatTuple {
|
||||
pub paren_token: token::Paren,
|
||||
pub front: Punctuated<Pat, Token![,]>,
|
||||
@ -722,12 +847,16 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A box pattern: `box v`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Box(PatBox {
|
||||
pub box_token: Token![box],
|
||||
pub pat: Box<Pat>,
|
||||
}),
|
||||
|
||||
/// A reference pattern: `&mut (first, second)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Ref(PatRef {
|
||||
pub and_token: Token![&],
|
||||
pub mutability: Option<Token![mut]>,
|
||||
@ -738,11 +867,15 @@ ast_enum_of_structs! {
|
||||
///
|
||||
/// This holds an `Expr` rather than a `Lit` because negative numbers
|
||||
/// are represented as an `Expr::Unary`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Lit(PatLit {
|
||||
pub expr: Box<Expr>,
|
||||
}),
|
||||
|
||||
/// A range pattern: `1..=2`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Range(PatRange {
|
||||
pub lo: Box<Expr>,
|
||||
pub limits: RangeLimits,
|
||||
@ -750,6 +883,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A dynamically sized slice pattern: `[a, b, i.., y, z]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Slice(PatSlice {
|
||||
pub bracket_token: token::Bracket,
|
||||
pub front: Punctuated<Pat, Token![,]>,
|
||||
@ -760,11 +895,15 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A macro in expression position.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Macro(PatMacro {
|
||||
pub mac: Macro,
|
||||
}),
|
||||
|
||||
/// Tokens in pattern position not interpreted by Syn.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Verbatim(PatVerbatim #manual_extra_traits {
|
||||
pub tts: TokenStream,
|
||||
}),
|
||||
@ -810,6 +949,8 @@ ast_struct! {
|
||||
/// # false
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct Arm {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub pats: Punctuated<Pat, Token![|]>,
|
||||
@ -823,6 +964,8 @@ ast_struct! {
|
||||
#[cfg(feature = "full")]
|
||||
ast_enum! {
|
||||
/// Limit types of a range, inclusive or exclusive.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
#[cfg_attr(feature = "clone-impls", derive(Copy))]
|
||||
pub enum RangeLimits {
|
||||
/// Inclusive at the beginning, exclusive at the end.
|
||||
@ -838,6 +981,8 @@ 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 if Syn is built with the `"full"` feature.*
|
||||
pub struct FieldPat {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub member: Member,
|
||||
|
@ -10,6 +10,8 @@ use super::*;
|
||||
|
||||
ast_struct! {
|
||||
/// A complete file of Rust source code.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct File {
|
||||
pub shebang: Option<String>,
|
||||
pub attrs: Vec<Attribute>,
|
||||
|
@ -12,6 +12,9 @@ use punctuated::Punctuated;
|
||||
ast_struct! {
|
||||
/// Lifetimes and type parameters attached to a declaration of a function,
|
||||
/// enum, trait, etc.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
#[derive(Default)]
|
||||
pub struct Generics {
|
||||
pub lt_token: Option<Token![<]>,
|
||||
@ -25,6 +28,9 @@ ast_enum_of_structs! {
|
||||
/// A generic type parameter, lifetime, or const generic: `T: Into<String>`,
|
||||
/// `'a: 'b`, `const LEN: usize`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -32,6 +38,9 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum GenericParam {
|
||||
/// A generic type parameter: `T: Into<String>`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Type(TypeParam {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub ident: Ident,
|
||||
@ -42,6 +51,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A lifetime definition: `'a: 'b + 'c + 'd`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Lifetime(LifetimeDef {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub lifetime: Lifetime,
|
||||
@ -50,6 +62,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A const generic parameter: `const LENGTH: usize`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Const(ConstParam {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub const_token: Token![const],
|
||||
@ -62,22 +77,31 @@ ast_enum_of_structs! {
|
||||
}
|
||||
}
|
||||
|
||||
/// Returned by `Generics::split_for_impl`.
|
||||
///
|
||||
/// *This type is available 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))]
|
||||
/// Returned by `Generics::split_for_impl`.
|
||||
pub struct ImplGenerics<'a>(&'a Generics);
|
||||
|
||||
/// Returned by `Generics::split_for_impl`.
|
||||
///
|
||||
/// *This type is available 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))]
|
||||
/// Returned by `Generics::split_for_impl`.
|
||||
pub struct TypeGenerics<'a>(&'a Generics);
|
||||
|
||||
/// Returned by `TypeGenerics::as_turbofish`.
|
||||
///
|
||||
/// *This type is available 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))]
|
||||
/// Returned by `TypeGenerics::as_turbofish`.
|
||||
pub struct Turbofish<'a>(&'a Generics);
|
||||
|
||||
#[cfg(feature = "printing")]
|
||||
@ -101,6 +125,9 @@ impl Generics {
|
||||
/// # ;
|
||||
/// # }
|
||||
/// ```
|
||||
///
|
||||
/// *This method is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature and the `"printing"` feature.*
|
||||
pub fn split_for_impl(&self) -> (ImplGenerics, TypeGenerics, Option<&WhereClause>) {
|
||||
(
|
||||
ImplGenerics(self),
|
||||
@ -113,6 +140,9 @@ impl Generics {
|
||||
#[cfg(feature = "printing")]
|
||||
impl<'a> TypeGenerics<'a> {
|
||||
/// Turn a type's generics like `<X, Y>` into a turbofish like `::<X, Y>`.
|
||||
///
|
||||
/// *This method is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature and the `"printing"` feature.*
|
||||
pub fn as_turbofish(&self) -> Turbofish {
|
||||
Turbofish(self.0)
|
||||
}
|
||||
@ -120,6 +150,9 @@ impl<'a> TypeGenerics<'a> {
|
||||
|
||||
ast_struct! {
|
||||
/// A set of bound lifetimes: `for<'a, 'b, 'c>`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
#[derive(Default)]
|
||||
pub struct BoundLifetimes {
|
||||
pub for_token: Token![for],
|
||||
@ -155,6 +188,9 @@ impl From<Ident> for TypeParam {
|
||||
|
||||
ast_enum_of_structs! {
|
||||
/// A trait or lifetime used as a bound on a type parameter.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum TypeParamBound {
|
||||
pub Trait(TraitBound),
|
||||
pub Lifetime(Lifetime),
|
||||
@ -163,6 +199,9 @@ ast_enum_of_structs! {
|
||||
|
||||
ast_struct! {
|
||||
/// A trait used as a bound on a type parameter.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct TraitBound {
|
||||
pub modifier: TraitBoundModifier,
|
||||
/// The `for<'a>` in `for<'a> Foo<&'a T>`
|
||||
@ -175,6 +214,9 @@ ast_struct! {
|
||||
ast_enum! {
|
||||
/// A modifier on a trait bound, currently only used for the `?` in
|
||||
/// `?Sized`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
#[cfg_attr(feature = "clone-impls", derive(Copy))]
|
||||
pub enum TraitBoundModifier {
|
||||
None,
|
||||
@ -185,6 +227,9 @@ ast_enum! {
|
||||
ast_struct! {
|
||||
/// A `where` clause in a definition: `where T: Deserialize<'de>, D:
|
||||
/// 'static`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct WhereClause {
|
||||
pub where_token: Token![where],
|
||||
pub predicates: Punctuated<WherePredicate, Token![,]>,
|
||||
@ -194,6 +239,9 @@ ast_struct! {
|
||||
ast_enum_of_structs! {
|
||||
/// A single predicate in a `where` clause: `T: Deserialize<'de>`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -201,6 +249,9 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum WherePredicate {
|
||||
/// A type predicate in a `where` clause: `for<'c> Foo<'c>: Trait<'c>`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Type(PredicateType {
|
||||
/// Any lifetimes from a `for` binding
|
||||
pub lifetimes: Option<BoundLifetimes>,
|
||||
@ -212,6 +263,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A lifetime predicate in a `where` clause: `'a: 'b + 'c`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Lifetime(PredicateLifetime {
|
||||
pub lifetime: Lifetime,
|
||||
pub colon_token: Option<Token![:]>,
|
||||
@ -219,6 +273,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// An equality predicate in a `where` clause (unsupported).
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Eq(PredicateEq {
|
||||
pub lhs_ty: Type,
|
||||
pub eq_token: Token![=],
|
||||
|
96
src/item.rs
96
src/item.rs
@ -20,6 +20,8 @@ use std::hash::{Hash, Hasher};
|
||||
ast_enum_of_structs! {
|
||||
/// Things that can appear directly inside of a module or scope.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -27,6 +29,8 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum Item {
|
||||
/// An `extern crate` item: `extern crate serde`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub ExternCrate(ItemExternCrate {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -38,6 +42,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A use declaration: `use std::collections::HashMap`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Use(ItemUse {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -49,6 +55,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A static item: `static BIKE: Shed = Shed(42)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Static(ItemStatic {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -63,6 +71,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A constant item: `const MAX: u16 = 65535`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Const(ItemConst {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -75,7 +85,10 @@ ast_enum_of_structs! {
|
||||
pub semi_token: Token![;],
|
||||
}),
|
||||
|
||||
/// A free-standing function: `fn process(n: usize) -> Result<()> { ... }`.
|
||||
/// A free-standing function: `fn process(n: usize) -> Result<()> { ...
|
||||
/// }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Fn(ItemFn {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -88,6 +101,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A module or module declaration: `mod m` or `mod m { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Mod(ItemMod {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -98,6 +113,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A block of foreign items: `extern "C" { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub ForeignMod(ItemForeignMod {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub abi: Abi,
|
||||
@ -106,6 +123,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A type alias: `type Result<T> = std::result::Result<T, MyError>`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Type(ItemType {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -118,6 +137,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A struct definition: `struct Foo<A> { x: A }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Struct(ItemStruct {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -129,6 +150,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// An enum definition: `enum Foo<A, B> { C<A>, D<B> }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Enum(ItemEnum {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -140,6 +163,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A union definition: `union Foo<A, B> { x: A, y: B }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Union(ItemUnion {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -150,6 +175,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A trait definition: `pub trait Iterator { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Trait(ItemTrait {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -166,6 +193,8 @@ ast_enum_of_structs! {
|
||||
|
||||
/// An impl block providing trait or associated items: `impl<A> Trait
|
||||
/// for Data<A> { ... }`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Impl(ItemImpl {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub defaultness: Option<Token![default]>,
|
||||
@ -181,6 +210,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A macro invocation, which includes `macro_rules!` definitions.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Macro(ItemMacro {
|
||||
pub attrs: Vec<Attribute>,
|
||||
/// The `example` in `macro_rules! example { ... }`.
|
||||
@ -190,6 +221,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A 2.0-style declarative macro introduced by the `macro` keyword.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Macro2(ItemMacro2 #manual_extra_traits {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -202,6 +235,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// Tokens forming an item not interpreted by Syn.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Verbatim(ItemVerbatim #manual_extra_traits {
|
||||
pub tts: TokenStream,
|
||||
}),
|
||||
@ -295,6 +330,8 @@ impl From<DeriveInput> for Item {
|
||||
ast_enum_of_structs! {
|
||||
/// A suffix of an import tree in a `use` item: `Type as Renamed` or `*`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -302,15 +339,23 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum UseTree {
|
||||
/// An identifier imported by a `use` item: `Type` or `Type as Renamed`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Path(UsePath {
|
||||
pub ident: Ident,
|
||||
pub rename: Option<(Token![as], Ident)>,
|
||||
}),
|
||||
|
||||
/// A glob import in a `use` item: `*`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Glob(UseGlob {
|
||||
pub star_token: Token![*],
|
||||
}),
|
||||
|
||||
/// A braced list of imports in a `use` item: `{A, B, C}`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub List(UseList {
|
||||
pub brace_token: token::Brace,
|
||||
pub items: Punctuated<UseTree, Token![,]>,
|
||||
@ -321,6 +366,8 @@ ast_enum_of_structs! {
|
||||
ast_enum_of_structs! {
|
||||
/// An item within an `extern` block.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -328,6 +375,8 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum ForeignItem {
|
||||
/// A foreign function in an `extern` block.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Fn(ForeignItemFn {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -337,6 +386,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A foreign static item in an `extern` block: `static ext: u8`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Static(ForeignItemStatic {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -349,6 +400,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A foreign type in an `extern` block: `type void`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Type(ForeignItemType {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -358,6 +411,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// Tokens in an `extern` block not interpreted by Syn.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Verbatim(ForeignItemVerbatim #manual_extra_traits {
|
||||
pub tts: TokenStream,
|
||||
}),
|
||||
@ -387,6 +442,8 @@ impl Hash for ForeignItemVerbatim {
|
||||
ast_enum_of_structs! {
|
||||
/// An item declaration within the definition of a trait.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -394,6 +451,8 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum TraitItem {
|
||||
/// An associated constant within the definition of a trait.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Const(TraitItemConst {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub const_token: Token![const],
|
||||
@ -405,6 +464,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A trait method within the definition of a trait.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Method(TraitItemMethod {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub sig: MethodSig,
|
||||
@ -413,6 +474,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// An associated type within the definition of a trait.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Type(TraitItemType {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub type_token: Token![type],
|
||||
@ -425,6 +488,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A macro invocation within the definition of a trait.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Macro(TraitItemMacro {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub mac: Macro,
|
||||
@ -432,6 +497,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// Tokens within the definition of a trait not interpreted by Syn.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Verbatim(TraitItemVerbatim #manual_extra_traits {
|
||||
pub tts: TokenStream,
|
||||
}),
|
||||
@ -461,6 +528,8 @@ impl Hash for TraitItemVerbatim {
|
||||
ast_enum_of_structs! {
|
||||
/// An item within an impl block.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -468,6 +537,8 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum ImplItem {
|
||||
/// An associated constant within an impl block.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Const(ImplItemConst {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -482,6 +553,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A method within an impl block.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Method(ImplItemMethod {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -491,6 +564,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// An associated type within an impl block.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Type(ImplItemType {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub vis: Visibility,
|
||||
@ -504,6 +579,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A macro invocation within an impl block.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Macro(ImplItemMacro {
|
||||
pub attrs: Vec<Attribute>,
|
||||
pub mac: Macro,
|
||||
@ -511,6 +588,8 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// Tokens within an impl block not interpreted by Syn.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Verbatim(ImplItemVerbatim #manual_extra_traits {
|
||||
pub tts: TokenStream,
|
||||
}),
|
||||
@ -540,6 +619,8 @@ impl Hash for ImplItemVerbatim {
|
||||
ast_struct! {
|
||||
/// A method's signature in a trait or implementation: `unsafe fn
|
||||
/// initialize(&self)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct MethodSig {
|
||||
pub constness: Option<Token![const]>,
|
||||
pub unsafety: Option<Token![unsafe]>,
|
||||
@ -551,6 +632,8 @@ ast_struct! {
|
||||
|
||||
ast_struct! {
|
||||
/// Header of a function declaration, without including the body.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub struct FnDecl {
|
||||
pub fn_token: Token![fn],
|
||||
pub generics: Generics,
|
||||
@ -566,6 +649,8 @@ ast_enum_of_structs! {
|
||||
///
|
||||
/// E.g. `bar: usize` as in `fn foo(bar: usize)`
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -574,24 +659,33 @@ ast_enum_of_structs! {
|
||||
pub enum FnArg {
|
||||
/// Self captured by reference in a function signature: `&self` or `&mut
|
||||
/// self`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub SelfRef(ArgSelfRef {
|
||||
pub and_token: Token![&],
|
||||
pub lifetime: Option<Lifetime>,
|
||||
pub mutability: Option<Token![mut]>,
|
||||
pub self_token: Token![self],
|
||||
}),
|
||||
|
||||
/// Self captured by value in a function signature: `self` or `mut
|
||||
/// self`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub SelfValue(ArgSelf {
|
||||
pub mutability: Option<Token![mut]>,
|
||||
pub self_token: Token![self],
|
||||
}),
|
||||
|
||||
/// An explicitly typed pattern captured by a function signature.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"full"` feature.*
|
||||
pub Captured(ArgCaptured {
|
||||
pub pat: Pat,
|
||||
pub colon_token: Token![:],
|
||||
pub ty: Type,
|
||||
}),
|
||||
|
||||
/// A pattern whose type is inferred captured by a function signature.
|
||||
pub Inferred(Pat),
|
||||
/// A type not bound to any pattern in a function signature.
|
||||
|
18
src/lib.rs
18
src/lib.rs
@ -418,6 +418,8 @@ mod gen {
|
||||
/// # fn visit_bin_op(&mut self, node: &'ast BinOp);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// *This module is available if Syn is built with the `"visit"` feature.*
|
||||
#[cfg(feature = "visit")]
|
||||
pub mod visit;
|
||||
|
||||
@ -453,6 +455,9 @@ mod gen {
|
||||
/// # fn visit_bin_op_mut(&mut self, node: &mut BinOp);
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// *This module is available if Syn is built with the `"visit-mut"`
|
||||
/// feature.*
|
||||
#[cfg(feature = "visit-mut")]
|
||||
pub mod visit_mut;
|
||||
|
||||
@ -489,6 +494,8 @@ mod gen {
|
||||
/// # fn fold_bin_op(&mut self, node: BinOp) -> BinOp;
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// *This module is available if Syn is built with the `"fold"` feature.*
|
||||
#[cfg(feature = "fold")]
|
||||
pub mod fold;
|
||||
|
||||
@ -528,6 +535,8 @@ pub use error::parse_error;
|
||||
///
|
||||
/// [`syn::parse2`]: fn.parse2.html
|
||||
///
|
||||
/// *This function is available if Syn is built with the `"parsing"` feature.*
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
@ -577,6 +586,8 @@ where
|
||||
///
|
||||
/// [`Macro`]: struct.Macro.html
|
||||
/// [`syn::parse`]: fn.parse.html
|
||||
///
|
||||
/// *This function is available if Syn is built with the `"parsing"` feature.*
|
||||
#[cfg(feature = "parsing")]
|
||||
pub fn parse2<T>(tokens: proc_macro2::TokenStream) -> Result<T, ParseError>
|
||||
where
|
||||
@ -605,6 +616,8 @@ where
|
||||
|
||||
/// Parse a string of Rust code into the chosen syntax tree node.
|
||||
///
|
||||
/// *This function is available if Syn is built with the `"parsing"` feature.*
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust
|
||||
@ -643,6 +656,8 @@ pub fn parse_str<T: Synom>(s: &str) -> Result<T, ParseError> {
|
||||
///
|
||||
/// If present, either of these would be an error using `from_str`.
|
||||
///
|
||||
/// *This function is available if Syn is built with the `"parsing"` feature.*
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```rust,no_run
|
||||
@ -725,6 +740,9 @@ pub fn parse_file(mut content: &str) -> Result<File, ParseError> {
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with both the `"parsing"` and
|
||||
/// `"printing"` features.*
|
||||
///
|
||||
/// # Example
|
||||
///
|
||||
/// The following helper function adds a bound `T: HeapSize` to every type
|
||||
|
@ -24,6 +24,9 @@ use unicode_xid::UnicodeXID;
|
||||
/// the XID_Start property.
|
||||
/// - All following characters must be Unicode code points with the XID_Continue
|
||||
/// property.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
#[cfg_attr(feature = "extra-traits", derive(Debug))]
|
||||
#[cfg_attr(feature = "clone-impls", derive(Clone))]
|
||||
pub struct Lifetime {
|
||||
|
36
src/lit.rs
36
src/lit.rs
@ -18,6 +18,9 @@ use std::hash::{Hash, Hasher};
|
||||
ast_enum_of_structs! {
|
||||
/// A Rust literal such as a string or integer or boolean.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -25,24 +28,36 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum Lit {
|
||||
/// A UTF-8 string literal: `"foo"`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Str(LitStr #manual_extra_traits {
|
||||
token: Literal,
|
||||
pub span: Span,
|
||||
}),
|
||||
|
||||
/// A byte string literal: `b"foo"`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub ByteStr(LitByteStr #manual_extra_traits {
|
||||
token: Literal,
|
||||
pub span: Span,
|
||||
}),
|
||||
|
||||
/// A byte literal: `b'f'`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Byte(LitByte #manual_extra_traits {
|
||||
token: Literal,
|
||||
pub span: Span,
|
||||
}),
|
||||
|
||||
/// A character literal: `'a'`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Char(LitChar #manual_extra_traits {
|
||||
token: Literal,
|
||||
pub span: Span,
|
||||
@ -52,6 +67,9 @@ ast_enum_of_structs! {
|
||||
///
|
||||
/// Holds up to 64 bits of data. Use `LitVerbatim` for any larger
|
||||
/// integer literal.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Int(LitInt #manual_extra_traits {
|
||||
token: Literal,
|
||||
pub span: Span,
|
||||
@ -60,12 +78,18 @@ ast_enum_of_structs! {
|
||||
/// A floating point literal: `1f64` or `1.0e10f64`.
|
||||
///
|
||||
/// Must be finite. May not be infinte or NaN.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Float(LitFloat #manual_extra_traits {
|
||||
token: Literal,
|
||||
pub span: Span,
|
||||
}),
|
||||
|
||||
/// A boolean literal: `true` or `false`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Bool(LitBool #manual_extra_traits {
|
||||
pub value: bool,
|
||||
pub span: Span,
|
||||
@ -73,6 +97,9 @@ ast_enum_of_structs! {
|
||||
|
||||
/// A raw token literal not interpreted by Syn, possibly because it
|
||||
/// represents an integer larger than 64 bits.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Verbatim(LitVerbatim #manual_extra_traits {
|
||||
pub token: Literal,
|
||||
pub span: Span,
|
||||
@ -245,6 +272,9 @@ lit_extra_traits!(LitVerbatim, token);
|
||||
ast_enum! {
|
||||
/// The style of a string literal, either plain quoted or a raw string like
|
||||
/// `r##"data"##`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum StrStyle #no_visit {
|
||||
/// An ordinary string like `"data"`.
|
||||
Cooked,
|
||||
@ -257,6 +287,9 @@ ast_enum! {
|
||||
|
||||
ast_enum! {
|
||||
/// The suffix on an integer literal if any, like the `u8` in `127u8`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum IntSuffix #no_visit {
|
||||
I8,
|
||||
I16,
|
||||
@ -277,6 +310,9 @@ ast_enum! {
|
||||
ast_enum! {
|
||||
/// The suffix on a floating point literal if any, like the `f32` in
|
||||
/// `1.0f32`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum FloatSuffix #no_visit {
|
||||
F32,
|
||||
F64,
|
||||
|
@ -17,6 +17,9 @@ use tt::TokenStreamHelper;
|
||||
|
||||
ast_struct! {
|
||||
/// A macro invocation: `println!("{}", mac)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct Macro #manual_extra_traits {
|
||||
pub path: Path,
|
||||
pub bang_token: Token![!],
|
||||
@ -27,6 +30,9 @@ ast_struct! {
|
||||
|
||||
ast_enum! {
|
||||
/// A grouping token that surrounds a macro body: `m!(...)` or `m!{...}` or `m![...]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum MacroDelimiter {
|
||||
Paren(Paren),
|
||||
Brace(Brace),
|
||||
|
@ -8,6 +8,9 @@
|
||||
|
||||
ast_enum! {
|
||||
/// A binary operator: `+`, `+=`, `&`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
#[cfg_attr(feature = "clone-impls", derive(Copy))]
|
||||
pub enum BinOp {
|
||||
/// The `+` operator (addition)
|
||||
@ -71,6 +74,9 @@ ast_enum! {
|
||||
|
||||
ast_enum! {
|
||||
/// A unary operator: `*`, `!`, `-`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
#[cfg_attr(feature = "clone-impls", derive(Copy))]
|
||||
pub enum UnOp {
|
||||
/// The `*` operator for dereferencing
|
||||
|
@ -60,6 +60,8 @@ use synom::PResult;
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! named {
|
||||
($name:ident -> $o:ty, $submac:ident!( $($args:tt)* )) => {
|
||||
@ -136,6 +138,8 @@ macro_rules! call {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[cfg(not(synom_verbose_trace))]
|
||||
#[macro_export]
|
||||
macro_rules! call {
|
||||
@ -175,6 +179,8 @@ macro_rules! call {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! map {
|
||||
($i:expr, $submac:ident!( $($args:tt)* ), $g:expr) => {
|
||||
@ -222,6 +228,8 @@ pub fn invoke<T, R, F: FnOnce(T) -> R>(f: F, t: T) -> R {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! not {
|
||||
($i:expr, $submac:ident!( $($args:tt)* )) => {
|
||||
@ -289,6 +297,8 @@ macro_rules! not {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! cond {
|
||||
($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => {
|
||||
@ -363,6 +373,8 @@ macro_rules! cond {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! cond_reduce {
|
||||
($i:expr, $cond:expr, $submac:ident!( $($args:tt)* )) => {
|
||||
@ -424,6 +436,8 @@ macro_rules! cond_reduce {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! many0 {
|
||||
($i:expr, $submac:ident!( $($args:tt)* )) => {{
|
||||
@ -564,6 +578,8 @@ pub fn many0<T>(mut input: Cursor, f: fn(Cursor) -> PResult<T>) -> PResult<Vec<T
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! switch {
|
||||
($i:expr, $submac:ident!( $($args:tt)* ), $($p:pat => $subrule:ident!( $($args2:tt)* ))|* ) => {
|
||||
@ -656,6 +672,8 @@ macro_rules! switch {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! value {
|
||||
($i:expr, $res:expr) => {
|
||||
@ -687,6 +705,8 @@ macro_rules! value {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! reject {
|
||||
($i:expr,) => {{
|
||||
@ -710,6 +730,8 @@ macro_rules! reject {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! tuple {
|
||||
($i:expr, $($rest:tt)*) => {
|
||||
@ -830,6 +852,8 @@ macro_rules! tuple_parser {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! alt {
|
||||
($i:expr, $e:ident | $($rest:tt)*) => {
|
||||
@ -922,6 +946,8 @@ macro_rules! alt {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! do_parse {
|
||||
($i:expr, ( $($rest:expr),* )) => {
|
||||
@ -1023,6 +1049,8 @@ macro_rules! do_parse {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! input_end {
|
||||
($i:expr,) => {
|
||||
@ -1081,6 +1109,8 @@ pub fn input_end(input: Cursor) -> PResult<'static, ()> {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! option {
|
||||
($i:expr, $submac:ident!( $($args:tt)* )) => {
|
||||
@ -1132,6 +1162,8 @@ macro_rules! option {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! epsilon {
|
||||
($i:expr,) => {
|
||||
@ -1210,6 +1242,8 @@ macro_rules! tap {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! syn {
|
||||
($i:expr, $t:ty) => {
|
||||
@ -1240,6 +1274,8 @@ macro_rules! syn {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! parens {
|
||||
($i:expr, $submac:ident!( $($args:tt)* )) => {
|
||||
@ -1274,6 +1310,8 @@ macro_rules! parens {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! brackets {
|
||||
($i:expr, $submac:ident!( $($args:tt)* )) => {
|
||||
@ -1308,6 +1346,8 @@ macro_rules! brackets {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[macro_export]
|
||||
macro_rules! braces {
|
||||
($i:expr, $submac:ident!( $($args:tt)* )) => {
|
||||
|
27
src/path.rs
27
src/path.rs
@ -11,6 +11,9 @@ use super::*;
|
||||
|
||||
ast_struct! {
|
||||
/// A path at which a named item is exported: `std::collections::HashMap`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct Path {
|
||||
pub leading_colon: Option<Token![::]>,
|
||||
pub segments: Punctuated<PathSegment, Token![::]>,
|
||||
@ -45,6 +48,9 @@ impl Path {
|
||||
/// #
|
||||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// *This type is available 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))]
|
||||
@ -66,6 +72,9 @@ where
|
||||
|
||||
ast_struct! {
|
||||
/// A segment of a path together with any path arguments on that segment.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct PathSegment {
|
||||
pub ident: Ident,
|
||||
pub arguments: PathArguments,
|
||||
@ -88,6 +97,9 @@ ast_enum! {
|
||||
/// Bracketed or parenthesized arguments of a path segment.
|
||||
///
|
||||
/// E.g. `<K, V>` as in `HashMap<K, V>` or `(A, B) -> C` as in `Fn(A, B) -> C`
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum PathArguments {
|
||||
None,
|
||||
/// The `<'a, T>` in `std::slice::iter<'a, T>`.
|
||||
@ -115,6 +127,9 @@ impl PathArguments {
|
||||
|
||||
ast_enum! {
|
||||
/// An individual generic argument, like `'a`, `T`, or `Item = T`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum GenericArgument {
|
||||
/// A lifetime argument.
|
||||
Lifetime(Lifetime),
|
||||
@ -135,6 +150,9 @@ ast_enum! {
|
||||
ast_struct! {
|
||||
/// Angle bracketed arguments of a path segment: the `<K, V>` in `HashMap<K,
|
||||
/// V>`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct AngleBracketedGenericArguments {
|
||||
pub colon2_token: Option<Token![::]>,
|
||||
pub lt_token: Token![<],
|
||||
@ -145,6 +163,9 @@ ast_struct! {
|
||||
|
||||
ast_struct! {
|
||||
/// A binding (equality constraint) on an associated type: `Item = u8`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct Binding {
|
||||
pub ident: Ident,
|
||||
pub eq_token: Token![=],
|
||||
@ -155,6 +176,9 @@ ast_struct! {
|
||||
ast_struct! {
|
||||
/// Arguments of a function path segment: the `(A, B)` and `C` in `Fn(A,B)
|
||||
/// -> C`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct ParenthesizedGenericArguments {
|
||||
pub paren_token: token::Paren,
|
||||
/// `(A, B)`
|
||||
@ -181,6 +205,9 @@ ast_struct! {
|
||||
/// ^~~~~~ ^
|
||||
/// ty position = 0
|
||||
/// ```
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct QSelf {
|
||||
pub lt_token: Token![<],
|
||||
pub ty: Box<Type>,
|
||||
|
@ -9,6 +9,9 @@
|
||||
//! A trait that can provide the `Span` of the complete contents of a syntax
|
||||
//! tree node.
|
||||
//!
|
||||
//! *This module is available 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
|
||||
@ -97,6 +100,9 @@ use quote::{ToTokens, Tokens};
|
||||
/// See the [module documentation] for an example.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This trait is available if Syn is built with both the `"parsing"` and
|
||||
/// `"printing"` features.*
|
||||
pub trait Spanned {
|
||||
/// Returns a `Span` covering the complete contents of this syntax tree
|
||||
/// node, or [`Span::call_site()`] if this node is empty.
|
||||
|
@ -41,6 +41,8 @@
|
||||
//! - [`syn!`](../macro.syn.html)
|
||||
//! - [`tuple!`](../macro.tuple.html)
|
||||
//! - [`value!`](../macro.value.html)
|
||||
//!
|
||||
//! *This module is available if Syn is built with the `"parsing"` feature.*
|
||||
|
||||
use proc_macro2::TokenStream;
|
||||
|
||||
@ -54,6 +56,8 @@ use buffer::Cursor;
|
||||
/// Refer to the [module documentation] for details about parsing in Syn.
|
||||
///
|
||||
/// [module documentation]: index.html
|
||||
///
|
||||
/// *This trait is available if Syn is built with the `"parsing"` feature.*
|
||||
pub trait Synom: Sized {
|
||||
fn parse(input: Cursor) -> PResult<Self>;
|
||||
|
||||
|
@ -480,6 +480,8 @@ macro_rules! Token {
|
||||
/// See the [token module] documentation for details and examples.
|
||||
///
|
||||
/// [token module]: token/index.html
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[cfg(feature = "parsing")]
|
||||
#[macro_export]
|
||||
macro_rules! punct {
|
||||
@ -535,6 +537,8 @@ macro_rules! punct {
|
||||
/// See the [token module] documentation for details and examples.
|
||||
///
|
||||
/// [token module]: token/index.html
|
||||
///
|
||||
/// *This macro is available if Syn is built with the `"parsing"` feature.*
|
||||
#[cfg(feature = "parsing")]
|
||||
#[macro_export]
|
||||
macro_rules! keyword {
|
||||
|
60
src/ty.rs
60
src/ty.rs
@ -17,6 +17,9 @@ use tt::TokenStreamHelper;
|
||||
ast_enum_of_structs! {
|
||||
/// The possible types that a Rust value could have.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
///
|
||||
/// # Syntax tree enum
|
||||
///
|
||||
/// This type is a [syntax tree enum].
|
||||
@ -24,12 +27,18 @@ ast_enum_of_structs! {
|
||||
/// [syntax tree enum]: enum.Expr.html#syntax-tree-enums
|
||||
pub enum Type {
|
||||
/// A dynamically sized slice type: `[T]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Slice(TypeSlice {
|
||||
pub bracket_token: token::Bracket,
|
||||
pub elem: Box<Type>,
|
||||
}),
|
||||
|
||||
/// A fixed size array type: `[T; n]`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Array(TypeArray {
|
||||
pub bracket_token: token::Bracket,
|
||||
pub elem: Box<Type>,
|
||||
@ -38,6 +47,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A raw pointer type: `*const T` or `*mut T`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Ptr(TypePtr {
|
||||
pub star_token: Token![*],
|
||||
pub const_token: Option<Token![const]>,
|
||||
@ -46,6 +58,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A reference type: `&'a T` or `&'a mut T`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Reference(TypeReference {
|
||||
pub and_token: Token![&],
|
||||
pub lifetime: Option<Lifetime>,
|
||||
@ -54,6 +69,9 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// A bare function type: `fn(usize) -> bool`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub BareFn(TypeBareFn {
|
||||
pub unsafety: Option<Token![unsafe]>,
|
||||
pub abi: Option<Abi>,
|
||||
@ -66,11 +84,17 @@ ast_enum_of_structs! {
|
||||
}),
|
||||
|
||||
/// The never type: `!`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Never(TypeNever {
|
||||
pub bang_token: Token![!],
|
||||
}),
|
||||
|
||||
/// A tuple type: `(A, B, C, String)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Tuple(TypeTuple {
|
||||
pub paren_token: token::Paren,
|
||||
pub elems: Punctuated<Type, Token![,]>,
|
||||
@ -80,6 +104,9 @@ ast_enum_of_structs! {
|
||||
/// self-type as in `<Vec<T> as SomeTrait>::Associated`.
|
||||
///
|
||||
/// Type arguments are stored in the Path itself.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Path(TypePath {
|
||||
pub qself: Option<QSelf>,
|
||||
pub path: Path,
|
||||
@ -87,6 +114,9 @@ ast_enum_of_structs! {
|
||||
|
||||
/// A trait object type `Bound1 + Bound2 + Bound3` where `Bound` is a
|
||||
/// trait or a lifetime.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub TraitObject(TypeTraitObject {
|
||||
pub dyn_token: Option<Token![dyn]>,
|
||||
pub bounds: Punctuated<TypeParamBound, Token![+]>,
|
||||
@ -94,34 +124,52 @@ ast_enum_of_structs! {
|
||||
|
||||
/// An `impl Bound1 + Bound2 + Bound3` type where `Bound` is a trait or
|
||||
/// a lifetime.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub ImplTrait(TypeImplTrait {
|
||||
pub impl_token: Token![impl],
|
||||
pub bounds: Punctuated<TypeParamBound, Token![+]>,
|
||||
}),
|
||||
|
||||
/// A parenthesized type equivalent to the inner type.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Paren(TypeParen {
|
||||
pub paren_token: token::Paren,
|
||||
pub elem: Box<Type>,
|
||||
}),
|
||||
|
||||
/// A type contained within invisible delimiters.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Group(TypeGroup {
|
||||
pub group_token: token::Group,
|
||||
pub elem: Box<Type>,
|
||||
}),
|
||||
|
||||
/// Indication that a type should be inferred by the compiler: `_`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Infer(TypeInfer {
|
||||
pub underscore_token: Token![_],
|
||||
}),
|
||||
|
||||
/// A macro in the type position.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Macro(TypeMacro {
|
||||
pub mac: Macro,
|
||||
}),
|
||||
|
||||
/// Tokens in type position not interpreted by Syn.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or
|
||||
/// `"full"` feature.*
|
||||
pub Verbatim(TypeVerbatim #manual_extra_traits {
|
||||
pub tts: TokenStream,
|
||||
}),
|
||||
@ -150,6 +198,9 @@ impl Hash for TypeVerbatim {
|
||||
|
||||
ast_struct! {
|
||||
/// The binary interface of a function: `extern "C"`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct Abi {
|
||||
pub extern_token: Token![extern],
|
||||
pub name: Option<LitStr>,
|
||||
@ -158,6 +209,9 @@ ast_struct! {
|
||||
|
||||
ast_struct! {
|
||||
/// An argument in a function type: the `usize` in `fn(usize) -> bool`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub struct BareFnArg {
|
||||
pub name: Option<(BareFnArgName, Token![:])>,
|
||||
pub ty: Type,
|
||||
@ -166,6 +220,9 @@ ast_struct! {
|
||||
|
||||
ast_enum! {
|
||||
/// Name of an argument in a function type: the `n` in `fn(n: usize)`.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum BareFnArgName {
|
||||
/// Argument given a name.
|
||||
Named(Ident),
|
||||
@ -176,6 +233,9 @@ ast_enum! {
|
||||
|
||||
ast_enum! {
|
||||
/// Return type of a function signature.
|
||||
///
|
||||
/// *This type is available if Syn is built with the `"derive"` or `"full"`
|
||||
/// feature.*
|
||||
pub enum ReturnType {
|
||||
/// Return type is not specified.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user