Skip to content

Commit 791f93c

Browse files
committed
Allow try blocks as the argument to return expressions
Fixes 76271
1 parent 51f79b6 commit 791f93c

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

compiler/rustc_ast/src/token.rs

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool {
173173
kw::Move,
174174
kw::Return,
175175
kw::True,
176+
kw::Try,
176177
kw::Unsafe,
177178
kw::While,
178179
kw::Yield,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// run-pass
2+
// compile-flags: --edition 2018
3+
4+
#![feature(try_blocks)]
5+
6+
fn issue_76271() -> Option<i32> {
7+
return try { 4 }
8+
}
9+
10+
fn main() {
11+
assert_eq!(issue_76271(), Some(4));
12+
}

0 commit comments

Comments
 (0)