Skip to content

Commit b220db0

Browse files
committed
Allow ! as the return type of proc/closure literals
Fixes #13490.
1 parent dee8423 commit b220db0

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

src/libsyntax/parse/parser.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4092,20 +4092,20 @@ impl<'a> Parser<'a> {
40924092
(optional_unboxed_closure_kind, args)
40934093
}
40944094
};
4095-
let output = if self.eat(&token::RARROW) {
4096-
self.parse_ty(true)
4095+
let (style, output) = if self.token == token::RARROW {
4096+
self.parse_ret_ty()
40974097
} else {
4098-
P(Ty {
4098+
(Return, P(Ty {
40994099
id: ast::DUMMY_NODE_ID,
41004100
node: TyInfer,
41014101
span: self.span,
4102-
})
4102+
}))
41034103
};
41044104

41054105
(P(FnDecl {
41064106
inputs: inputs_captures,
41074107
output: output,
4108-
cf: Return,
4108+
cf: style,
41094109
variadic: false
41104110
}), optional_unboxed_closure_kind)
41114111
}
@@ -4118,20 +4118,20 @@ impl<'a> Parser<'a> {
41184118
seq_sep_trailing_allowed(token::COMMA),
41194119
|p| p.parse_fn_block_arg());
41204120

4121-
let output = if self.eat(&token::RARROW) {
4122-
self.parse_ty(true)
4121+
let (style, output) = if self.token == token::RARROW {
4122+
self.parse_ret_ty()
41234123
} else {
4124-
P(Ty {
4124+
(Return, P(Ty {
41254125
id: ast::DUMMY_NODE_ID,
41264126
node: TyInfer,
41274127
span: self.span,
4128-
})
4128+
}))
41294129
};
41304130

41314131
P(FnDecl {
41324132
inputs: inputs,
41334133
output: output,
4134-
cf: Return,
4134+
cf: style,
41354135
variadic: false
41364136
})
41374137
}

src/test/run-pass/closure-syntax.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ fn bar<'b>() {
7878

7979
let a = A;
8080
a.foo::<<'a>||>();
81+
82+
// issue #13490
83+
let _ = || -> ! loop {};
84+
let _ = proc() -> ! loop {};
8185
}
8286

8387
struct B<T>;

0 commit comments

Comments
 (0)