@@ -30,6 +30,13 @@ impl<'a> Parser<'a> {
3030 self . parse_ty_common ( true , true , false )
3131 }
3232
33+ /// Parse a type suitable for a function or function pointer parameter.
34+ /// The difference from `parse_ty` is that this version allows `...`
35+ /// (`CVarArgs`) at the top level of the the type.
36+ pub ( super ) fn parse_ty_for_param ( & mut self , allow_c_variadic : bool ) -> PResult < ' a , P < Ty > > {
37+ self . parse_ty_common ( true , true , allow_c_variadic)
38+ }
39+
3340 /// Parses a type in restricted contexts where `+` is not permitted.
3441 ///
3542 /// Example 1: `&'a TYPE`
@@ -41,17 +48,26 @@ impl<'a> Parser<'a> {
4148 }
4249
4350 /// Parses an optional return type `[ -> TY ]` in a function declaration.
44- pub ( super ) fn parse_ret_ty ( & mut self , allow_plus : bool ) -> PResult < ' a , FunctionRetTy > {
51+ pub ( super ) fn parse_ret_ty (
52+ & mut self ,
53+ allow_plus : bool ,
54+ allow_qpath_recovery : bool ,
55+ ) -> PResult < ' a , FunctionRetTy > {
4556 Ok ( if self . eat ( & token:: RArrow ) {
4657 // FIXME(Centril): Can we unconditionally `allow_plus`?
47- FunctionRetTy :: Ty ( self . parse_ty_common ( allow_plus, true , false ) ?)
58+ FunctionRetTy :: Ty ( self . parse_ty_common ( allow_plus, allow_qpath_recovery , false ) ?)
4859 } else {
4960 FunctionRetTy :: Default ( self . token . span . shrink_to_lo ( ) )
5061 } )
5162 }
5263
53- pub ( super ) fn parse_ty_common ( & mut self , allow_plus : bool , allow_qpath_recovery : bool ,
54- allow_c_variadic : bool ) -> PResult < ' a , P < Ty > > {
64+ fn parse_ty_common (
65+ & mut self ,
66+ allow_plus : bool ,
67+ allow_qpath_recovery : bool ,
68+ // Is `...` (`CVarArgs`) legal in the immediate top level call?
69+ allow_c_variadic : bool ,
70+ ) -> PResult < ' a , P < Ty > > {
5571 maybe_recover_from_interpolated_ty_qpath ! ( self , allow_qpath_recovery) ;
5672 maybe_whole ! ( self , NtTy , |x| x) ;
5773
@@ -198,6 +214,8 @@ impl<'a> Parser<'a> {
198214 self . eat ( & token:: DotDotDot ) ;
199215 TyKind :: CVarArgs
200216 } else {
217+ // FIXME(Centril): Should we just allow `...` syntactically
218+ // anywhere in a type and use semantic restrictions instead?
201219 return Err ( struct_span_fatal ! (
202220 self . sess. span_diagnostic,
203221 self . token. span,
0 commit comments