diff --git a/src/item.rs b/src/item.rs index 8f6746f056..28ccf8dd9a 100644 --- a/src/item.rs +++ b/src/item.rs @@ -2469,7 +2469,8 @@ pub mod parsing { || (input.peek2(Ident) || input.peek2(Lifetime)) && (input.peek3(Token![:]) || input.peek3(Token![,]) - || input.peek3(Token![>])) + || input.peek3(Token![>]) + || input.peek3(Token![=])) || input.peek2(Token![const])); let mut generics: Generics = if has_generics { input.parse()? diff --git a/tests/test_item.rs b/tests/test_item.rs index 70763e4ea1..a991e62d33 100644 --- a/tests/test_item.rs +++ b/tests/test_item.rs @@ -275,3 +275,27 @@ fn test_impl_visibility() { snapshot!(tokens as Item, @"Verbatim(`pub default unsafe impl union { }`)"); } + +#[test] +fn test_impl_type_parameter_defaults() { + #[cfg(any())] + impl () {} + let tokens = quote! { + impl () {} + }; + snapshot!(tokens as Item, @r###" + Item::Impl { + generics: Generics { + lt_token: Some, + params: [ + Type(TypeParam { + ident: "T", + eq_token: Some, + default: Some(Type::Tuple), + }), + ], + gt_token: Some, + }, + self_ty: Type::Tuple, + }"###); +}