diff --git a/src/generics.rs b/src/generics.rs index c755151d4..f2136aa5d 100644 --- a/src/generics.rs +++ b/src/generics.rs @@ -772,6 +772,27 @@ pub(crate) mod parsing { let begin = input.fork(); + if cfg!(feature = "full") && input.peek(Token![use]) { + input.parse::()?; + input.parse::()?; + while !input.peek(Token![>]) { + if input.peek(Lifetime) { + input.parse::()?; + } else if input.peek(Ident) { + input.parse::()?; + } else { + break; + } + if input.peek(Token![,]) { + input.parse::()?; + } else { + break; + } + } + input.parse::]>()?; + return Ok(TypeParamBound::Verbatim(verbatim::between(&begin, input))); + } + let content; let (paren_token, content) = if input.peek(token::Paren) { (Some(parenthesized!(content in input)), &content) diff --git a/tests/test_ty.rs b/tests/test_ty.rs index f1ced9ea3..d85479de4 100644 --- a/tests/test_ty.rs +++ b/tests/test_ty.rs @@ -395,3 +395,50 @@ fn test_tuple_comma() { } "###); } + +#[test] +fn test_impl_trait_use() { + let tokens = quote! { + impl Sized + use<'_, 'a, A, Test> + }; + + snapshot!(tokens as Type, @r###" + Type::ImplTrait { + bounds: [ + TypeParamBound::Trait(TraitBound { + path: Path { + segments: [ + PathSegment { + ident: "Sized", + }, + ], + }, + }), + Token![+], + TypeParamBound::Verbatim(`use < '_ , 'a , A , Test >`), + ], + } + "###); + + let trailing = quote! { + impl Sized + use<'_,> + }; + + snapshot!(trailing as Type, @r###" + Type::ImplTrait { + bounds: [ + TypeParamBound::Trait(TraitBound { + path: Path { + segments: [ + PathSegment { + ident: "Sized", + }, + ], + }, + }), + Token![+], + TypeParamBound::Verbatim(`use < '_ , >`), + ], + } + "###); +}