aboutsummaryrefslogtreecommitdiff
path: root/tests/test_ty.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_ty.rs')
-rw-r--r--tests/test_ty.rs68
1 files changed, 68 insertions, 0 deletions
diff --git a/tests/test_ty.rs b/tests/test_ty.rs
index 7e20dd99..907fb201 100644
--- a/tests/test_ty.rs
+++ b/tests/test_ty.rs
@@ -217,3 +217,71 @@ fn test_group_colons() {
}
"###);
}
+
+#[test]
+fn test_trait_object() {
+ let tokens = quote!(dyn for<'a> Trait<'a> + 'static);
+ snapshot!(tokens as Type, @r###"
+ Type::TraitObject {
+ dyn_token: Some,
+ bounds: [
+ Trait(TraitBound {
+ modifier: None,
+ lifetimes: Some(BoundLifetimes {
+ lifetimes: [
+ LifetimeDef {
+ lifetime: Lifetime {
+ ident: "a",
+ },
+ },
+ ],
+ }),
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "Trait",
+ arguments: PathArguments::AngleBracketed {
+ args: [
+ Lifetime(Lifetime {
+ ident: "a",
+ }),
+ ],
+ },
+ },
+ ],
+ },
+ }),
+ Lifetime(Lifetime {
+ ident: "static",
+ }),
+ ],
+ }
+ "###);
+
+ let tokens = quote!(dyn 'a + Trait);
+ snapshot!(tokens as Type, @r###"
+ Type::TraitObject {
+ dyn_token: Some,
+ bounds: [
+ Lifetime(Lifetime {
+ ident: "a",
+ }),
+ Trait(TraitBound {
+ modifier: None,
+ path: Path {
+ segments: [
+ PathSegment {
+ ident: "Trait",
+ arguments: None,
+ },
+ ],
+ },
+ }),
+ ],
+ }
+ "###);
+
+ // None of the following are valid Rust types.
+ syn::parse_str::<Type>("for<'a> dyn Trait<'a>").unwrap_err();
+ syn::parse_str::<Type>("dyn for<'a> 'a + Trait").unwrap_err();
+}