File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -2386,6 +2386,11 @@ impl<'a> Parser<'a> {
23862386 BlockCheckMode :: Unsafe ( ast:: UserProvided ) ,
23872387 attrs) ;
23882388 }
2389+ if self . is_do_catch_block ( ) {
2390+ let mut db = self . fatal ( "found removed `do catch` syntax" ) ;
2391+ db. help ( "Following RFC #2388, the new non-placeholder syntax is `try`" ) ;
2392+ return Err ( db) ;
2393+ }
23892394 if self . is_try_block ( ) {
23902395 let lo = self . span ;
23912396 assert ! ( self . eat_keyword( keywords:: Try ) ) ;
@@ -4406,6 +4411,13 @@ impl<'a> Parser<'a> {
44064411 )
44074412 }
44084413
4414+ fn is_do_catch_block ( & mut self ) -> bool {
4415+ self . token . is_keyword ( keywords:: Do ) &&
4416+ self . look_ahead ( 1 , |t| t. is_keyword ( keywords:: Catch ) ) &&
4417+ self . look_ahead ( 2 , |t| * t == token:: OpenDelim ( token:: Brace ) ) &&
4418+ !self . restrictions . contains ( Restrictions :: NO_STRUCT_LITERAL )
4419+ }
4420+
44094421 fn is_try_block ( & mut self ) -> bool {
44104422 self . token . is_keyword ( keywords:: Try ) &&
44114423 self . look_ahead ( 1 , |t| * t == token:: OpenDelim ( token:: Brace ) ) &&
Original file line number Diff line number Diff line change 1+ // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ // compile-flags: -Z parse-only
12+
13+ fn main ( ) {
14+ let _: Option < ( ) > = do catch { } ;
15+ //~^ ERROR found removed `do catch` syntax
16+ //~^^ HELP Following RFC #2388, the new non-placeholder syntax is `try`
17+ }
You can’t perform that action at this time.
0 commit comments