]> git.proxmox.com Git - rustc.git/blobdiff - vendor/syn/tests/test_generics.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / vendor / syn / tests / test_generics.rs
index 55c79e066b5bec0347a2396d66a837648a259ef9..e863b77900b044495d7c482dd09ab094abbfde3d 100644 (file)
@@ -1,6 +1,3 @@
-extern crate quote;
-extern crate syn;
-
 mod features;
 
 #[macro_use]
@@ -16,90 +13,90 @@ fn test_split_for_impl() {
     };
 
     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;
@@ -131,46 +128,46 @@ fn test_split_for_impl() {
 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,
+                },
+            ],
+        },
+    })
     "###);
 }
 
@@ -187,76 +184,76 @@ fn test_fn_precedence_in_where_clause() {
     };
 
     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();