about summary refs log tree commit diff
path: root/src/libsyntax/parse
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2018-08-19 17:51:02 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2018-08-19 17:51:02 -0700
commit009547141729b6d66f721065820edf9ddbde4831 (patch)
treebe2c79586d7a24a323bee68cbf01c1019fa54f34 /src/libsyntax/parse
parente4280852ae8ff32494c1ca6e4fe76e9e4a15dd31 (diff)
downloadrust-009547141729b6d66f721065820edf9ddbde4831.tar.gz
rust-009547141729b6d66f721065820edf9ddbde4831.zip
Switch out another use of `do catch`
Diffstat (limited to 'src/libsyntax/parse')
-rw-r--r--src/libsyntax/parse/parser.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index ad57530474c..b766fbd0d71 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -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()?)