-extern crate quote;
-extern crate syn;
-
mod features;
#[macro_use]
};
snapshot!(input as DeriveInput, @r###"
- ⋮DeriveInput {
- ⋮ vis: Inherited,
- ⋮ ident: "S",
- ⋮ generics: Generics {
- ⋮ lt_token: Some,
- ⋮ params: [
- ⋮ Lifetime(LifetimeDef {
- ⋮ lifetime: Lifetime {
- ⋮ ident: "a",
- ⋮ },
- ⋮ }),
- ⋮ Lifetime(LifetimeDef {
- ⋮ lifetime: Lifetime {
- ⋮ ident: "b",
- ⋮ },
- ⋮ colon_token: Some,
- ⋮ bounds: [
- ⋮ Lifetime {
- ⋮ ident: "a",
- ⋮ },
- ⋮ ],
- ⋮ }),
- ⋮ Type(TypeParam {
- ⋮ attrs: [
- ⋮ Attribute {
- ⋮ style: Outer,
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "may_dangle",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ tokens: ``,
- ⋮ },
- ⋮ ],
- ⋮ ident: "T",
- ⋮ colon_token: Some,
- ⋮ bounds: [
- ⋮ Lifetime(Lifetime {
- ⋮ ident: "a",
- ⋮ }),
- ⋮ ],
- ⋮ eq_token: Some,
- ⋮ default: Some(Type::Tuple),
- ⋮ }),
- ⋮ ],
- ⋮ gt_token: Some,
- ⋮ where_clause: Some(WhereClause {
- ⋮ predicates: [
- ⋮ Type(PredicateType {
- ⋮ bounded_ty: Type::Path {
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "T",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ },
- ⋮ bounds: [
- ⋮ Trait(TraitBound {
- ⋮ modifier: None,
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "Debug",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ }),
- ⋮ ],
- ⋮ }),
- ⋮ ],
- ⋮ }),
- ⋮ },
- ⋮ data: Data::Struct {
- ⋮ fields: Unit,
- ⋮ semi_token: Some,
- ⋮ },
- ⋮}
+ DeriveInput {
+ vis: Inherited,
+ ident: "S",
+ generics: Generics {
+ lt_token: Some,
+ params: [
+ Lifetime(LifetimeDef {
+ lifetime: Lifetime {
+ ident: "a",
+ },
+ }),
+ Lifetime(LifetimeDef {
+ lifetime: Lifetime {
+ ident: "b",
+ },
+ colon_token: Some,
+ bounds: [
+ Lifetime {
+ ident: "a",
+ },
+ ],
+ }),
+ Type(TypeParam {
+ attrs: [
+ Attribute {
+ style: Outer,
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "may_dangle",
+ arguments: None,
+ },
+ ],
+ },
+ tokens: ``,
+ },
+ ],
+ ident: "T",
+ colon_token: Some,
+ bounds: [
+ Lifetime(Lifetime {
+ ident: "a",
+ }),
+ ],
+ eq_token: Some,
+ default: Some(Type::Tuple),
+ }),
+ ],
+ gt_token: Some,
+ where_clause: Some(WhereClause {
+ predicates: [
+ Type(PredicateType {
+ bounded_ty: Type::Path {
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "T",
+ arguments: None,
+ },
+ ],
+ },
+ },
+ bounds: [
+ Trait(TraitBound {
+ modifier: None,
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "Debug",
+ arguments: None,
+ },
+ ],
+ },
+ }),
+ ],
+ }),
+ ],
+ }),
+ },
+ data: Data::Struct {
+ fields: Unit,
+ semi_token: Some,
+ },
+ }
"###);
let generics = input.generics;
fn test_ty_param_bound() {
let tokens = quote!('a);
snapshot!(tokens as TypeParamBound, @r###"
- ⋮Lifetime(Lifetime {
- ⋮ ident: "a",
- ⋮})
+ Lifetime(Lifetime {
+ ident: "a",
+ })
"###);
let tokens = quote!('_);
snapshot!(tokens as TypeParamBound, @r###"
- ⋮Lifetime(Lifetime {
- ⋮ ident: "_",
- ⋮})
+ Lifetime(Lifetime {
+ ident: "_",
+ })
"###);
let tokens = quote!(Debug);
snapshot!(tokens as TypeParamBound, @r###"
- ⋮Trait(TraitBound {
- ⋮ modifier: None,
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "Debug",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮})
+ Trait(TraitBound {
+ modifier: None,
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "Debug",
+ arguments: None,
+ },
+ ],
+ },
+ })
"###);
let tokens = quote!(?Sized);
snapshot!(tokens as TypeParamBound, @r###"
- ⋮Trait(TraitBound {
- ⋮ modifier: Maybe,
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "Sized",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮})
+ Trait(TraitBound {
+ modifier: Maybe,
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "Sized",
+ arguments: None,
+ },
+ ],
+ },
+ })
"###);
}
};
snapshot!(input as ItemFn, @r###"
- ⋮ItemFn {
- ⋮ vis: Inherited,
- ⋮ sig: Signature {
- ⋮ ident: "f",
- ⋮ generics: Generics {
- ⋮ lt_token: Some,
- ⋮ params: [
- ⋮ Type(TypeParam {
- ⋮ ident: "G",
- ⋮ }),
- ⋮ ],
- ⋮ gt_token: Some,
- ⋮ where_clause: Some(WhereClause {
- ⋮ predicates: [
- ⋮ Type(PredicateType {
- ⋮ bounded_ty: Type::Path {
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "G",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ },
- ⋮ bounds: [
- ⋮ Trait(TraitBound {
- ⋮ modifier: None,
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "FnOnce",
- ⋮ arguments: PathArguments::Parenthesized {
- ⋮ output: Type(
- ⋮ Type::Path {
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "i32",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ },
- ⋮ ),
- ⋮ },
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ }),
- ⋮ Trait(TraitBound {
- ⋮ modifier: None,
- ⋮ path: Path {
- ⋮ segments: [
- ⋮ PathSegment {
- ⋮ ident: "Send",
- ⋮ arguments: None,
- ⋮ },
- ⋮ ],
- ⋮ },
- ⋮ }),
- ⋮ ],
- ⋮ }),
- ⋮ ],
- ⋮ }),
- ⋮ },
- ⋮ output: Default,
- ⋮ },
- ⋮ block: Block,
- ⋮}
+ ItemFn {
+ vis: Inherited,
+ sig: Signature {
+ ident: "f",
+ generics: Generics {
+ lt_token: Some,
+ params: [
+ Type(TypeParam {
+ ident: "G",
+ }),
+ ],
+ gt_token: Some,
+ where_clause: Some(WhereClause {
+ predicates: [
+ Type(PredicateType {
+ bounded_ty: Type::Path {
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "G",
+ arguments: None,
+ },
+ ],
+ },
+ },
+ bounds: [
+ Trait(TraitBound {
+ modifier: None,
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "FnOnce",
+ arguments: PathArguments::Parenthesized {
+ output: Type(
+ Type::Path {
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "i32",
+ arguments: None,
+ },
+ ],
+ },
+ },
+ ),
+ },
+ },
+ ],
+ },
+ }),
+ Trait(TraitBound {
+ modifier: None,
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "Send",
+ arguments: None,
+ },
+ ],
+ },
+ }),
+ ],
+ }),
+ ],
+ }),
+ },
+ output: Default,
+ },
+ block: Block,
+ }
"###);
let where_clause = input.sig.generics.where_clause.as_ref().unwrap();