File tree 3 files changed +33
-9
lines changed
3 files changed +33
-9
lines changed Original file line number Diff line number Diff line change @@ -2086,15 +2086,13 @@ impl Parser {
2086
2086
fn parse_non_delim_tt_tok ( p : & Parser ) -> token_tree {
2087
2087
maybe_whole ! ( deref p, nt_tt) ;
2088
2088
match * p. token {
2089
- token:: RPAREN | token:: RBRACE | token:: RBRACKET
2090
- => {
2091
- p. fatal (
2092
- format ! (
2093
- "incorrect close delimiter: `{}`" ,
2094
- p. this_token_to_str( )
2095
- )
2096
- ) ;
2097
- }
2089
+ token:: RPAREN | token:: RBRACE | token:: RBRACKET => {
2090
+ // This is a conservative error: only report the last unclosed delimiter. The
2091
+ // previous unclosed delimiters could actually be closed! The parser just hasn't
2092
+ // gotten to them yet.
2093
+ p. open_braces . last_opt ( ) . map ( |sp| p. span_note ( * sp, "unclosed delimiter" ) ) ;
2094
+ p. fatal ( format ! ( "incorrect close delimiter: `{}`" , p. this_token_to_str( ) ) ) ;
2095
+ } ,
2098
2096
/* we ought to allow different depths of unquotation */
2099
2097
token:: DOLLAR if * p. quote_depth > 0 u => {
2100
2098
p. bump ( ) ;
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 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
+ struct Obj { //~ NOTE: unclosed delimiter
12
+ member : uint
13
+ ) //~ ERROR: incorrect close delimiter
Original file line number Diff line number Diff line change
1
+ // Copyright 2013 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
+ pub fn trace_option ( option : Option < int > ) {
12
+ option. map ( |some| 42 ; //~ NOTE: unclosed delimiter
13
+ } //~ ERROR: incorrect close delimiter
You can’t perform that action at this time.
0 commit comments