@@ -343,7 +343,8 @@ pub mod parsing {
343343 impl Parse for Type {
344344 fn parse ( input : ParseStream ) -> Result < Self > {
345345 let allow_plus = true ;
346- ambig_ty ( input, allow_plus)
346+ let allow_group_generic = true ;
347+ ambig_ty ( input, allow_plus, allow_group_generic)
347348 }
348349 }
349350
@@ -356,11 +357,16 @@ pub mod parsing {
356357 #[ cfg_attr( doc_cfg, doc( cfg( feature = "parsing" ) ) ) ]
357358 pub fn without_plus ( input : ParseStream ) -> Result < Self > {
358359 let allow_plus = false ;
359- ambig_ty ( input, allow_plus)
360+ let allow_group_generic = true ;
361+ ambig_ty ( input, allow_plus, allow_group_generic)
360362 }
361363 }
362364
363- fn ambig_ty ( input : ParseStream , allow_plus : bool ) -> Result < Type > {
365+ pub ( crate ) fn ambig_ty (
366+ input : ParseStream ,
367+ allow_plus : bool ,
368+ allow_group_generic : bool ,
369+ ) -> Result < Type > {
364370 let begin = input. fork ( ) ;
365371
366372 if input. peek ( token:: Group ) {
@@ -381,7 +387,9 @@ pub mod parsing {
381387 path : Path :: parse_helper ( input, false ) ?,
382388 } ) ) ;
383389 }
384- } else if input. peek ( Token ! [ <] ) || input. peek ( Token ! [ :: ] ) && input. peek3 ( Token ! [ <] ) {
390+ } else if input. peek ( Token ! [ <] ) && allow_group_generic
391+ || input. peek ( Token ! [ :: ] ) && input. peek3 ( Token ! [ <] )
392+ {
385393 if let Type :: Path ( mut ty) = * group. elem {
386394 let arguments = & mut ty. path . segments . last_mut ( ) . unwrap ( ) . arguments ;
387395 if let PathArguments :: None = arguments {
@@ -863,7 +871,8 @@ pub mod parsing {
863871 pub ( crate ) fn parse ( input : ParseStream , allow_plus : bool ) -> Result < Self > {
864872 if input. peek ( Token ! [ ->] ) {
865873 let arrow = input. parse ( ) ?;
866- let ty = ambig_ty ( input, allow_plus) ?;
874+ let allow_group_generic = true ;
875+ let ty = ambig_ty ( input, allow_plus, allow_group_generic) ?;
867876 Ok ( ReturnType :: Type ( arrow, Box :: new ( ty) ) )
868877 } else {
869878 Ok ( ReturnType :: Default )
@@ -986,7 +995,10 @@ pub mod parsing {
986995 let content;
987996 Ok ( TypeParen {
988997 paren_token : parenthesized ! ( content in input) ,
989- elem : Box :: new ( ambig_ty ( & content, allow_plus) ?) ,
998+ elem : Box :: new ( {
999+ let allow_group_generic = true ;
1000+ ambig_ty ( & content, allow_plus, allow_group_generic) ?
1001+ } ) ,
9901002 } )
9911003 }
9921004 }
0 commit comments