diff --git a/src/generics.rs b/src/generics.rs index de8e09151e..283c604dce 100644 --- a/src/generics.rs +++ b/src/generics.rs @@ -705,7 +705,11 @@ pub(crate) mod parsing { let mut bounds = Punctuated::new(); if colon_token.is_some() { loop { - if input.peek(Token![,]) || input.peek(Token![>]) || input.peek(Token![=]) { + if input.is_empty() + || input.peek(Token![,]) + || input.peek(Token![>]) + || input.peek(Token![=]) + { break; } bounds.push_value({ diff --git a/tests/test_generics.rs b/tests/test_generics.rs index 2cb05251c1..61bc8dea1c 100644 --- a/tests/test_generics.rs +++ b/tests/test_generics.rs @@ -343,3 +343,14 @@ fn no_opaque_drop() { lifetime }); } + +#[test] +fn type_param_with_colon_and_no_bounds() { + let tokens = quote!(T:); + snapshot!(tokens as GenericParam, @r#" + GenericParam::Type(TypeParam { + ident: "T", + colon_token: Some, + }) + "#); +}