Skip to content

Commit

Permalink
Allow try blocks as the argument to return expressions
Browse files Browse the repository at this point in the history
Fixes 76271
  • Loading branch information
scottmcm committed Sep 3, 2020
1 parent 51f79b6 commit 791f93c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions compiler/rustc_ast/src/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ pub fn ident_can_begin_expr(name: Symbol, span: Span, is_raw: bool) -> bool {
kw::Move,
kw::Return,
kw::True,
kw::Try,
kw::Unsafe,
kw::While,
kw::Yield,
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/try-block/try-block-in-return.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// run-pass
// compile-flags: --edition 2018

#![feature(try_blocks)]

fn issue_76271() -> Option<i32> {
return try { 4 }
}

fn main() {
assert_eq!(issue_76271(), Some(4));
}

0 comments on commit 791f93c

Please sign in to comment.