File tree 2 files changed +29
-0
lines changed
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> {
2386
2386
BlockCheckMode :: Unsafe ( ast:: UserProvided ) ,
2387
2387
attrs) ;
2388
2388
}
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
+ }
2389
2394
if self . is_try_block ( ) {
2390
2395
let lo = self . span ;
2391
2396
assert ! ( self . eat_keyword( keywords:: Try ) ) ;
@@ -4406,6 +4411,13 @@ impl<'a> Parser<'a> {
4406
4411
)
4407
4412
}
4408
4413
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
+
4409
4421
fn is_try_block ( & mut self ) -> bool {
4410
4422
self . token . is_keyword ( keywords:: Try ) &&
4411
4423
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