mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-01 11:13:43 +00:00
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:
commit
5b41887e0e
@ -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();
|
||||
}
|
||||
|
11
src/test/ui/parser/unmatched-delimiter-at-end-of-file.rs
Normal file
11
src/test/ui/parser/unmatched-delimiter-at-end-of-file.rs
Normal 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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user