Rollup merge of #56910 - estebank:unclosed-eof, r=oli-obk

Do not point at delim spans for complete correct blocks

Fix #56834.
This commit is contained in:
Pietro Albini 2018-12-19 11:47:14 +01:00 committed by GitHub
commit 5b41887e0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 1 deletions

View File

@ -97,7 +97,15 @@ impl<'a> StringReader<'a> {
// Correct delimiter.
token::CloseDelim(d) if d == delim => {
let (open_brace, open_brace_span) = self.open_braces.pop().unwrap();
self.matching_delim_spans.push((open_brace, open_brace_span, self.span));
if self.open_braces.len() == 0 {
// Clear up these spans to avoid suggesting them as we've found
// properly matched delimiters so far for an entire block.
self.matching_delim_spans.clear();
} else {
self.matching_delim_spans.push(
(open_brace, open_brace_span, self.span),
);
}
// Parse the close delimiter.
self.real_token();
}

View File

@ -0,0 +1,11 @@
struct S {
x: usize,
y: usize,
}
fn main() {
S { x: 4,
y: 5 };
}
fn foo() { //~ ERROR this file contains an un-closed delimiter

View File

@ -0,0 +1,8 @@
error: this file contains an un-closed delimiter
--> $DIR/unmatched-delimiter-at-end-of-file.rs:11:64
|
LL | fn foo() { //~ ERROR this file contains an un-closed delimiter
| - un-closed delimiter ^
error: aborting due to previous error