Skip to content

Commit 0095471

Browse files
committed
Switch out another use of do catch
1 parent e428085 commit 0095471

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

src/libsyntax/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
#![feature(rustc_diagnostic_macros)]
2727
#![feature(slice_sort_by_cached_key)]
2828
#![feature(str_escape)]
29+
#![feature(try_trait)]
2930
#![feature(unicode_internals)]
30-
#![feature(catch_expr)]
3131

3232
#![recursion_limit="256"]
3333

src/libsyntax/parse/parser.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1756,9 +1756,17 @@ impl<'a> Parser<'a> {
17561756

17571757
let parser_snapshot_before_pat = self.clone();
17581758

1759+
// Once we can use edition 2018 in the compiler,
1760+
// replace this with real try blocks.
1761+
macro_rules! try_block {
1762+
($($inside:tt)*) => (
1763+
(||{ ::std::ops::Try::from_ok({ $($inside)* }) })()
1764+
)
1765+
}
1766+
17591767
// We're going to try parsing the argument as a pattern (even though it's not
17601768
// allowed). This way we can provide better errors to the user.
1761-
let pat_arg: PResult<'a, _> = do catch {
1769+
let pat_arg: PResult<'a, _> = try_block! {
17621770
let pat = self.parse_pat()?;
17631771
self.expect(&token::Colon)?;
17641772
(pat, self.parse_ty()?)

0 commit comments

Comments
 (0)