File tree Expand file tree Collapse file tree 9 files changed +98
-9
lines changed Expand file tree Collapse file tree 9 files changed +98
-9
lines changed Original file line number Diff line number Diff line change @@ -23,7 +23,7 @@ refs/tags/0.9: 36870b185fc5f5486636d4515f0e22677493f225
23
23
refs/tags/0.10: ac33f2b15782272ae348dbd7b14b8257b2148b5a
24
24
refs/tags/0.11.0: e1247cb1d0d681be034adb4b558b5a0c0d5720f9
25
25
refs/tags/0.12.0: f0c419429ef30723ceaf6b42f9b5a2aeb5d2e2d1
26
- refs/heads/beta: 2731dc169c3e35707049575829cb106e2bdc9801
26
+ refs/heads/beta: 180d6b55ca19c63347664f0622b6ccc37fb101f5
27
27
refs/tags/1.0.0-alpha: e42bd6d93a1d3433c486200587f8f9e12590a4d7
28
28
refs/heads/tmp: e06d2ad9fcd5027bcaac5b08fc9aa39a49d0ecd3
29
29
refs/tags/1.0.0-alpha.2: 4c705f6bc559886632d3871b04f58aab093bfa2f
Original file line number Diff line number Diff line change @@ -2841,7 +2841,12 @@ impl<'a> Parser<'a> {
2841
2841
maybe_whole ! ( deref self , NtTT ) ;
2842
2842
match self . token {
2843
2843
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)
2845
2850
} ,
2846
2851
/* we ought to allow different depths of unquotation */
2847
2852
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
2
2
// file at the top-level directory of this distribution and at
3
3
// http://rust-lang.org/COPYRIGHT.
4
4
//
11
11
// FIXME(31528) we emit a bunch of silly errors here due to continuing past the
12
12
// first one. This would be easy-ish to address by better recovery in tokenisation.
13
13
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 > ) {
17
15
option. map ( |some| 42 ; //~ NOTE: unclosed delimiter
18
16
//~^ ERROR: expected one of
17
+ //~^^ ERROR: mismatched types
19
18
} //~ ERROR: incorrect close delimiter
20
19
//~^ 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 10
10
11
11
// compile-flags: -Z parse-only
12
12
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() {
14
14
foo! (
15
15
bar, "baz" , 1 , 2.0
16
16
} //~ ERROR incorrect close delimiter
17
- }
17
+ } //~ ERROR unexpected close delimiter: `}`
You can’t perform that action at this time.
0 commit comments