@@ -2960,13 +2960,30 @@ impl<'a> Parser<'a> {
2960
2960
let parser_snapshot_before_ty = this. create_snapshot_for_diagnostic ( ) ;
2961
2961
this. eat_incorrect_doc_comment_for_param_type ( ) ;
2962
2962
let mut ty = this. parse_ty_for_param ( ) ;
2963
- if ty. is_ok ( )
2964
- && this. token != token:: Comma
2965
- && this. token != token:: CloseDelim ( Delimiter :: Parenthesis )
2966
- {
2967
- // This wasn't actually a type, but a pattern looking like a type,
2968
- // so we are going to rollback and re-parse for recovery.
2969
- ty = this. unexpected_any ( ) ;
2963
+
2964
+ if let Ok ( t) = & ty {
2965
+ // Check for trailing angle brackets
2966
+ if let TyKind :: Path ( _, Path { segments, .. } ) = & t. kind {
2967
+ if let Some ( segment) = segments. last ( ) {
2968
+ if let Some ( guar) =
2969
+ this. check_trailing_angle_brackets ( segment, & [ exp ! ( CloseParen ) ] )
2970
+ {
2971
+ return Ok ( (
2972
+ dummy_arg ( segment. ident , guar) ,
2973
+ Trailing :: No ,
2974
+ UsePreAttrPos :: No ,
2975
+ ) ) ;
2976
+ }
2977
+ }
2978
+ }
2979
+
2980
+ if this. token != token:: Comma
2981
+ && this. token != token:: CloseDelim ( Delimiter :: Parenthesis )
2982
+ {
2983
+ // This wasn't actually a type, but a pattern looking like a type,
2984
+ // so we are going to rollback and re-parse for recovery.
2985
+ ty = this. unexpected_any ( ) ;
2986
+ }
2970
2987
}
2971
2988
match ty {
2972
2989
Ok ( ty) => {
@@ -2977,6 +2994,7 @@ impl<'a> Parser<'a> {
2977
2994
}
2978
2995
// If this is a C-variadic argument and we hit an error, return the error.
2979
2996
Err ( err) if this. token == token:: DotDotDot => return Err ( err) ,
2997
+ Err ( err) if this. unmatched_angle_bracket_count > 0 => return Err ( err) ,
2980
2998
// Recover from attempting to parse the argument as a type without pattern.
2981
2999
Err ( err) => {
2982
3000
err. cancel ( ) ;
0 commit comments