Skip to content

Commit

Permalink
add more testcase for issue 68987
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Nov 11, 2022
1 parent 0868f18 commit 01babdc
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/rustc_parse/src/lexer/tokentrees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl<'a> TokenTreesReader<'a> {
"...as it matches this but it has different indentation",
);

// If there is a empty block in the mismatched span, note it
// If there is a empty block in the mismatched span, note it
for span in self.empty_block_spans.keys() {
if let Some(d) = self.empty_block_spans.get(span) &&
*d == delim && block_span.contains(*span) {
Expand Down
12 changes: 12 additions & 0 deletions src/test/ui/parser/issue-68987-unmatch-issue-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
async fn obstest() -> Result<> {
let obs_connect = || -> Result<(), MyError) { //~ ERROR mismatched closing delimiter
async {
}
}

if let Ok(version, scene_list) = obs_connect() {

} else {

}
} //~ ERROR unexpected closing delimiter
16 changes: 16 additions & 0 deletions src/test/ui/parser/issue-68987-unmatch-issue-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
error: unexpected closing delimiter: `}`
--> $DIR/issue-68987-unmatch-issue-2.rs:12:1
|
LL | }
| ^ unexpected closing delimiter

error: mismatched closing delimiter: `)`
--> $DIR/issue-68987-unmatch-issue-2.rs:1:32
|
LL | async fn obstest() -> Result<> {
| ^ unclosed delimiter
LL | let obs_connect = || -> Result<(), MyError) {
| ^ mismatched closing delimiter

error: aborting due to 2 previous errors

7 changes: 7 additions & 0 deletions src/test/ui/parser/issue-68987-unmatch-issue-3.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
fn f(i: u32, j: u32) {
let res = String::new();
let mut cnt = i;
while cnt < j {
write!&mut res, " "); //~ ERROR mismatched closing delimiter
}
} //~ ERROR unexpected closing delimiter
21 changes: 21 additions & 0 deletions src/test/ui/parser/issue-68987-unmatch-issue-3.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
error: unexpected closing delimiter: `}`
--> $DIR/issue-68987-unmatch-issue-3.rs:7:1
|
LL | fn f(i: u32, j: u32) {
| - this delimiter might not be properly closed...
...
LL | }
| - ...as it matches this but it has different indentation
LL | }
| ^ unexpected closing delimiter

error: mismatched closing delimiter: `)`
--> $DIR/issue-68987-unmatch-issue-3.rs:4:19
|
LL | while cnt < j {
| ^ unclosed delimiter
LL | write!&mut res, " ");
| ^ mismatched closing delimiter

error: aborting due to 2 previous errors

0 comments on commit 01babdc

Please sign in to comment.