Skip to content

Commit 25b3c82

Browse files
committed
Do not point at delim spans for complete correct blocks
1 parent f4a421e commit 25b3c82

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/libsyntax/parse/lexer/tokentrees.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,15 @@ impl<'a> StringReader<'a> {
9797
// Correct delimiter.
9898
token::CloseDelim(d) if d == delim => {
9999
let (open_brace, open_brace_span) = self.open_braces.pop().unwrap();
100-
self.matching_delim_spans.push((open_brace, open_brace_span, self.span));
100+
if self.open_braces.len() == 0 {
101+
// Clear up these spans to avoid suggesting them as we've found
102+
// properly matched delimiters so far for an entire block.
103+
self.matching_delim_spans.clear();
104+
} else {
105+
self.matching_delim_spans.push(
106+
(open_brace, open_brace_span, self.span),
107+
);
108+
}
101109
// Parse the close delimiter.
102110
self.real_token();
103111
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
struct S {
2+
x: usize,
3+
y: usize,
4+
}
5+
6+
fn main() {
7+
S { x: 4,
8+
y: 5 };
9+
}
10+
11+
fn foo() { //~ ERROR this file contains an un-closed delimiter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: this file contains an un-closed delimiter
2+
--> $DIR/unmatched-delimiter-at-end-of-file.rs:11:64
3+
|
4+
LL | fn foo() { //~ ERROR this file contains an un-closed delimiter
5+
| - un-closed delimiter ^
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)