diff --git a/compiler/rustc_parse/src/lexer/tokentrees.rs b/compiler/rustc_parse/src/lexer/tokentrees.rs index ec5575917de13..2eb565a679f00 100644 --- a/compiler/rustc_parse/src/lexer/tokentrees.rs +++ b/compiler/rustc_parse/src/lexer/tokentrees.rs @@ -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) { diff --git a/src/test/ui/parser/issue-68987-unmatch-issue-2.rs b/src/test/ui/parser/issue-68987-unmatch-issue-2.rs new file mode 100644 index 0000000000000..e833143c6edb0 --- /dev/null +++ b/src/test/ui/parser/issue-68987-unmatch-issue-2.rs @@ -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 diff --git a/src/test/ui/parser/issue-68987-unmatch-issue-2.stderr b/src/test/ui/parser/issue-68987-unmatch-issue-2.stderr new file mode 100644 index 0000000000000..fe195e3da4215 --- /dev/null +++ b/src/test/ui/parser/issue-68987-unmatch-issue-2.stderr @@ -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 + diff --git a/src/test/ui/parser/issue-68987-unmatch-issue-3.rs b/src/test/ui/parser/issue-68987-unmatch-issue-3.rs new file mode 100644 index 0000000000000..fea994479e44f --- /dev/null +++ b/src/test/ui/parser/issue-68987-unmatch-issue-3.rs @@ -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 diff --git a/src/test/ui/parser/issue-68987-unmatch-issue-3.stderr b/src/test/ui/parser/issue-68987-unmatch-issue-3.stderr new file mode 100644 index 0000000000000..ff81916053c92 --- /dev/null +++ b/src/test/ui/parser/issue-68987-unmatch-issue-3.stderr @@ -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 +