File tree Expand file tree Collapse file tree 8 files changed +97
-8
lines changed Expand file tree Collapse file tree 8 files changed +97
-8
lines changed Original file line number Diff line number Diff line change @@ -2841,7 +2841,12 @@ impl<'a> Parser<'a> {
28412841                maybe_whole ! ( deref self ,  NtTT ) ; 
28422842                match  self . token  { 
28432843                    token:: CloseDelim ( _)  => { 
2844-                         panic ! ( "should have been caught above" ) ; 
2844+                         // An unexpected closing delimiter (i.e., there is no 
2845+                         // matching opening delimiter). 
2846+                         let  token_str = self . this_token_to_string ( ) ; 
2847+                         let  err = self . diagnostic ( ) . struct_span_err ( self . span , 
2848+                             & format ! ( "unexpected close delimiter: `{}`" ,  token_str) ) ; 
2849+                         Err ( err) 
28452850                    } , 
28462851                    /* we ought to allow different depths of unquotation */ 
28472852                    token:: Dollar  | token:: SubstNt ( ..)  if  self . quote_depth  > 0  => { 
Original file line number Diff line number Diff line change 1- // Copyright 2013 The Rust Project Developers. See the COPYRIGHT 
1+ // Copyright 2013-2016  The Rust Project Developers. See the COPYRIGHT 
22// file at the top-level directory of this distribution and at 
33// http://rust-lang.org/COPYRIGHT. 
44// 
1111// FIXME(31528) we emit a bunch of silly errors here due to continuing past the 
1212// first one. This would be easy-ish to address by better recovery in tokenisation. 
1313
14- // compile-flags: -Z parse-only 
15- 
16- pub  fn  trace_option ( option :  Option < isize > )  {  //~ HELP did you mean to close this delimiter? 
14+ pub  fn  trace_option ( option :  Option < isize > )  { 
1715    option. map ( |some| 42 ;  //~ NOTE: unclosed delimiter 
1816                          //~^ ERROR: expected one of 
17+                           //~^^ ERROR: mismatched types 
1918}  //~ ERROR: incorrect close delimiter 
2019//~^ ERROR: expected one of 
21- //~ ERROR: this file contains an un-closed delimiter 
Original file line number Diff line number Diff line change 1+ // Copyright 2016 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+ // Test that error recovery in the parser to an EOF does not give an infinite 
12+ // spew of errors. 
13+ 
14+ fn  main ( )  { 
15+     let 
16+ }  //~ ERROR unexpected token: `}` 
Original file line number Diff line number Diff line change 1+ // Copyright 2016 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+ // Test that we do some basic error correcton in the tokeniser (and don't ICE). 
12+ 
13+ fn  main( )  { 
14+     if  foo {  //~ NOTE: unclosed delimiter 
15+     //~^ ERROR: unresolved name `foo` 
16+     )  //~ ERROR: incorrect close delimiter: `)` 
17+ } 
Original file line number Diff line number Diff line change 1+ // Copyright 2016 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+ // Test that we do some basic error correcton in the tokeniser (and don't spew 
12+ // too many bogus errors). 
13+ 
14+ pub  mod  raw { 
15+     use  std:: { io,  fs} ; 
16+     use  std:: path:: Path ; 
17+ 
18+     pub  fn  ensure_dir_exists < P :  AsRef < Path > ,  F :  FnOnce ( & Path ) > ( path :  P , 
19+                                                                callback :  F ) 
20+                                                                -> io:: Result < bool >  { 
21+         if  !is_directory ( path. as_ref ( ) )  {  //~ ERROR: unresolved name `is_directory` 
22+             callback ( path. as_ref ( ) ;   //~ NOTE: unclosed delimiter 
23+                      //~^ ERROR: expected one of 
24+             fs:: create_dir_all ( path. as_ref ( ) ) . map ( |( ) | true )  //~ ERROR: expected one of 
25+         }  else  {  //~ ERROR: incorrect close delimiter: `}` 
26+             Ok ( false ) ; 
27+         } 
28+ 
29+         panic ! ( ) ; 
30+     } 
31+ } 
32+ 
33+ fn  main ( )  { } 
Original file line number Diff line number Diff line change 1+ // Copyright 2016 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+ // Test that we do some basic error correcton in the tokeniser. 
12+ 
13+ fn  main( )  { 
14+     foo( bar( ;  //~ NOTE: unclosed delimiter 
15+     //~^ NOTE: unclosed delimiter 
16+     //~^^ ERROR: unexpected token: `;` 
17+     //~^^^ ERROR: unresolved name `bar` 
18+     //~^^^^ ERROR: unresolved name `foo` 
19+ }  //~ ERROR: incorrect close delimiter: `}` 
20+ //~^ ERROR: incorrect close delimiter: `}` 
Original file line number Diff line number Diff line change 1010
1111// compile-flags: -Z parse-only 
1212
13- static  foo:  isize  = 2 ;  }  //~ ERROR incorrect  close delimiter: 
13+ static  foo:  isize  = 2 ;  }  //~ ERROR unexpected  close delimiter: 
Original file line number Diff line number Diff line change @@ -14,4 +14,4 @@ fn main() {
1414    foo! ( 
1515        bar,  "baz" ,  1 ,  2.0 
1616    }  //~ ERROR incorrect close delimiter 
17- } 
17+ }   //~ ERROR unexpected close delimiter: `}` 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments