about summary refs log tree commit diff
path: root/src/libsyntax/parse/parser.rs
diff options
context:
space:
mode:
authorScott McMurray <scottmcm@users.noreply.github.com>2018-07-24 17:55:36 -0700
committerScott McMurray <scottmcm@users.noreply.github.com>2018-08-19 16:53:42 -0700
commit817efc2489806b8188c2f5693fb3b0dcf9c76eb1 (patch)
tree4207e449a909b32308c0b9ccb134f15d09bb95ba /src/libsyntax/parse/parser.rs
parent91967a8f163b44eb46bdac130ffded7752ae298c (diff)
downloadrust-817efc2489806b8188c2f5693fb3b0dcf9c76eb1.tar.gz
rust-817efc2489806b8188c2f5693fb3b0dcf9c76eb1.zip
Suggest `try` if someone uses `do catch`
Diffstat (limited to 'src/libsyntax/parse/parser.rs')
-rw-r--r--src/libsyntax/parse/parser.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs
index 2b0cfd14a3d..ad57530474c 100644
--- a/src/libsyntax/parse/parser.rs
+++ b/src/libsyntax/parse/parser.rs
@@ -2386,6 +2386,11 @@ impl<'a> Parser<'a> {
                         BlockCheckMode::Unsafe(ast::UserProvided),
                         attrs);
                 }
+                if self.is_do_catch_block() {
+                    let mut db = self.fatal("found removed `do catch` syntax");
+                    db.help("Following RFC #2388, the new non-placeholder syntax is `try`");
+                    return Err(db);
+                }
                 if self.is_try_block() {
                     let lo = self.span;
                     assert!(self.eat_keyword(keywords::Try));
@@ -4406,6 +4411,13 @@ impl<'a> Parser<'a> {
         )
     }
 
+    fn is_do_catch_block(&mut self) -> bool {
+        self.token.is_keyword(keywords::Do) &&
+        self.look_ahead(1, |t| t.is_keyword(keywords::Catch)) &&
+        self.look_ahead(2, |t| *t == token::OpenDelim(token::Brace)) &&
+        !self.restrictions.contains(Restrictions::NO_STRUCT_LITERAL)
+    }
+
     fn is_try_block(&mut self) -> bool {
         self.token.is_keyword(keywords::Try) &&
         self.look_ahead(1, |t| *t == token::OpenDelim(token::Brace)) &&