Allow ! as the return type of proc/closure literals

Fixes #13490.
This commit is contained in:
P1start 2014-08-29 17:16:23 +12:00
parent dee8423531
commit b220db03bd
2 changed files with 14 additions and 10 deletions

View File

@ -4092,20 +4092,20 @@ fn parse_fn_block_decl(&mut self)
(optional_unboxed_closure_kind, args) (optional_unboxed_closure_kind, args)
} }
}; };
let output = if self.eat(&token::RARROW) { let (style, output) = if self.token == token::RARROW {
self.parse_ty(true) self.parse_ret_ty()
} else { } else {
P(Ty { (Return, P(Ty {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: TyInfer, node: TyInfer,
span: self.span, span: self.span,
}) }))
}; };
(P(FnDecl { (P(FnDecl {
inputs: inputs_captures, inputs: inputs_captures,
output: output, output: output,
cf: Return, cf: style,
variadic: false variadic: false
}), optional_unboxed_closure_kind) }), optional_unboxed_closure_kind)
} }
@ -4118,20 +4118,20 @@ fn parse_proc_decl(&mut self) -> P<FnDecl> {
seq_sep_trailing_allowed(token::COMMA), seq_sep_trailing_allowed(token::COMMA),
|p| p.parse_fn_block_arg()); |p| p.parse_fn_block_arg());
let output = if self.eat(&token::RARROW) { let (style, output) = if self.token == token::RARROW {
self.parse_ty(true) self.parse_ret_ty()
} else { } else {
P(Ty { (Return, P(Ty {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
node: TyInfer, node: TyInfer,
span: self.span, span: self.span,
}) }))
}; };
P(FnDecl { P(FnDecl {
inputs: inputs, inputs: inputs,
output: output, output: output,
cf: Return, cf: style,
variadic: false variadic: false
}) })
} }

View File

@ -78,6 +78,10 @@ fn bar<'b>() {
let a = A; let a = A;
a.foo::<<'a>||>(); a.foo::<<'a>||>();
// issue #13490
let _ = || -> ! loop {};
let _ = proc() -> ! loop {};
} }
struct B<T>; struct B<T>;