diff --git a/src/ty.rs b/src/ty.rs index 3df340d5d7..6e9f1f4316 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -919,6 +919,14 @@ pub mod parsing { break; } bounds.push_punct(input.parse()?); + if !(input.peek(Ident::peek_any) + || input.peek(Token![::]) + || input.peek(Token![?]) + || input.peek(Lifetime) + || input.peek(token::Paren)) + { + break; + } } bounds }, diff --git a/tests/test_item.rs b/tests/test_item.rs index a991e62d33..96df4b1aad 100644 --- a/tests/test_item.rs +++ b/tests/test_item.rs @@ -299,3 +299,38 @@ fn test_impl_type_parameter_defaults() { self_ty: Type::Tuple, }"###); } + +#[test] +fn test_impl_trait_trailing_plus() { + let tokens = quote! { + fn f() -> impl Sized + {} + }; + + snapshot!(tokens as Item, @r###" + Item::Fn { + vis: Inherited, + sig: Signature { + ident: "f", + generics: Generics, + output: Type( + Type::ImplTrait { + bounds: [ + Trait(TraitBound { + modifier: None, + path: Path { + segments: [ + PathSegment { + ident: "Sized", + arguments: None, + }, + ], + }, + }), + ], + }, + ), + }, + block: Block, + } + "###); +}