Skip to content

Commit

Permalink
Switch out another use of do catch
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Aug 20, 2018
1 parent e428085 commit 0095471
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#![feature(rustc_diagnostic_macros)]
#![feature(slice_sort_by_cached_key)]
#![feature(str_escape)]
#![feature(try_trait)]
#![feature(unicode_internals)]
#![feature(catch_expr)]

#![recursion_limit="256"]

Expand Down
10 changes: 9 additions & 1 deletion src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1756,9 +1756,17 @@ impl<'a> Parser<'a> {

let parser_snapshot_before_pat = self.clone();

// Once we can use edition 2018 in the compiler,
// replace this with real try blocks.
macro_rules! try_block {
($($inside:tt)*) => (
(||{ ::std::ops::Try::from_ok({ $($inside)* }) })()
)
}

// We're going to try parsing the argument as a pattern (even though it's not
// allowed). This way we can provide better errors to the user.
let pat_arg: PResult<'a, _> = do catch {
let pat_arg: PResult<'a, _> = try_block! {
let pat = self.parse_pat()?;
self.expect(&token::Colon)?;
(pat, self.parse_ty()?)
Expand Down

0 comments on commit 0095471

Please sign in to comment.