Skip to content

Commit

Permalink
Collect occurrences of for mismatched braces diagnostic
Browse files Browse the repository at this point in the history
Change-Id: I20ba0b62308370ee961141fa1aefc4b9c9f0cb3a
  • Loading branch information
XiangQingW committed Oct 15, 2019
1 parent 888d0ba commit fe819a0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/libsyntax/parse/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ impl<'a> TokenTreesReader<'a> {
let (open_brace, open_brace_span) = self.open_braces.pop().unwrap();
let close_brace_span = self.token.span;

if close_brace_span.lo() == open_brace_span.hi() {
if tts.is_empty() {
let empty_block_span = open_brace_span.to(close_brace_span);
self.last_delim_empty_block_spans.insert(delim, empty_block_span);
}
Expand Down
4 changes: 3 additions & 1 deletion src/test/ui/parser/mismatched-delim-brace-empty-block.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
fn main() {}
fn main() {

}
let _ = ();
} //~ ERROR unexpected close delimiter
15 changes: 9 additions & 6 deletions src/test/ui/parser/mismatched-delim-brace-empty-block.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
error: unexpected close delimiter: `}`
--> $DIR/mismatched-delim-brace-empty-block.rs:3:1
--> $DIR/mismatched-delim-brace-empty-block.rs:5:1
|
LL | fn main() {}
| -- this block is empty, you might have not meant to close it
LL | let _ = ();
LL | }
| ^ unexpected close delimiter
LL | fn main() {
| ___________-
LL | |
LL | | }
| |_- this block is empty, you might have not meant to close it
LL | let _ = ();
LL | }
| ^ unexpected close delimiter

error: aborting due to previous error

0 comments on commit fe819a0

Please sign in to comment.