syntax: Permit +
in return types of function declarations
`+` is still disallowed in function types and function-like traits
This commit is contained in:
parent
873b77531c
commit
95d27c3b79
2 changed files with 7 additions and 7 deletions
|
@ -1362,7 +1362,7 @@ impl<'a> Parser<'a> {
|
||||||
|
|
||||||
self.expect_keyword(keywords::Fn)?;
|
self.expect_keyword(keywords::Fn)?;
|
||||||
let (inputs, variadic) = self.parse_fn_args(false, true)?;
|
let (inputs, variadic) = self.parse_fn_args(false, true)?;
|
||||||
let ret_ty = self.parse_ret_ty()?;
|
let ret_ty = self.parse_ret_ty(false)?;
|
||||||
let decl = P(FnDecl {
|
let decl = P(FnDecl {
|
||||||
inputs,
|
inputs,
|
||||||
output: ret_ty,
|
output: ret_ty,
|
||||||
|
@ -1501,9 +1501,9 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Parse optional return type [ -> TY ] in function decl
|
/// Parse optional return type [ -> TY ] in function decl
|
||||||
pub fn parse_ret_ty(&mut self) -> PResult<'a, FunctionRetTy> {
|
fn parse_ret_ty(&mut self, allow_plus: bool) -> PResult<'a, FunctionRetTy> {
|
||||||
if self.eat(&token::RArrow) {
|
if self.eat(&token::RArrow) {
|
||||||
Ok(FunctionRetTy::Ty(self.parse_ty_no_plus()?))
|
Ok(FunctionRetTy::Ty(self.parse_ty_common(allow_plus, true)?))
|
||||||
} else {
|
} else {
|
||||||
Ok(FunctionRetTy::Default(self.span.with_hi(self.span.lo())))
|
Ok(FunctionRetTy::Default(self.span.with_hi(self.span.lo())))
|
||||||
}
|
}
|
||||||
|
@ -4893,7 +4893,7 @@ impl<'a> Parser<'a> {
|
||||||
pub fn parse_fn_decl(&mut self, allow_variadic: bool) -> PResult<'a, P<FnDecl>> {
|
pub fn parse_fn_decl(&mut self, allow_variadic: bool) -> PResult<'a, P<FnDecl>> {
|
||||||
|
|
||||||
let (args, variadic) = self.parse_fn_args(true, allow_variadic)?;
|
let (args, variadic) = self.parse_fn_args(true, allow_variadic)?;
|
||||||
let ret_ty = self.parse_ret_ty()?;
|
let ret_ty = self.parse_ret_ty(true)?;
|
||||||
|
|
||||||
Ok(P(FnDecl {
|
Ok(P(FnDecl {
|
||||||
inputs: args,
|
inputs: args,
|
||||||
|
@ -5034,7 +5034,7 @@ impl<'a> Parser<'a> {
|
||||||
self.expect(&token::CloseDelim(token::Paren))?;
|
self.expect(&token::CloseDelim(token::Paren))?;
|
||||||
Ok(P(FnDecl {
|
Ok(P(FnDecl {
|
||||||
inputs: fn_inputs,
|
inputs: fn_inputs,
|
||||||
output: self.parse_ret_ty()?,
|
output: self.parse_ret_ty(true)?,
|
||||||
variadic: false
|
variadic: false
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
@ -5056,7 +5056,7 @@ impl<'a> Parser<'a> {
|
||||||
args
|
args
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let output = self.parse_ret_ty()?;
|
let output = self.parse_ret_ty(true)?;
|
||||||
|
|
||||||
Ok(P(FnDecl {
|
Ok(P(FnDecl {
|
||||||
inputs: inputs_captures,
|
inputs: inputs_captures,
|
||||||
|
|
|
@ -72,7 +72,7 @@ mod m {
|
||||||
impl TraitWithAssocTy for u8 { type AssocTy = Priv; }
|
impl TraitWithAssocTy for u8 { type AssocTy = Priv; }
|
||||||
//~^ ERROR private type `m::Priv` in public interface
|
//~^ ERROR private type `m::Priv` in public interface
|
||||||
|
|
||||||
pub fn leak_anon1() -> (impl Trait + 'static) { 0 }
|
pub fn leak_anon1() -> impl Trait + 'static { 0 }
|
||||||
pub fn leak_anon2() -> impl TraitWithTyParam<Alias> { 0 }
|
pub fn leak_anon2() -> impl TraitWithTyParam<Alias> { 0 }
|
||||||
pub fn leak_anon3() -> impl TraitWithAssocTy<AssocTy = Alias> { 0 }
|
pub fn leak_anon3() -> impl TraitWithAssocTy<AssocTy = Alias> { 0 }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue