add testcase for #104012

This commit is contained in:
yukang 2023-01-26 10:52:57 +08:00
parent 1f72129ffe
commit c4d00d710c
14 changed files with 216 additions and 0 deletions

View File

@ -0,0 +1,25 @@
// error-pattern: this file contains an unclosed delimiter
#![feature(let_chains)]
trait Demo {}
impl dyn Demo {
pub fn report(&self) -> u32 {
let sum = |a: u32,
b: u32,
c: u32| {
a + b + c
};
sum(1, 2, 3)
}
fn check(&self, val: Option<u32>, num: Option<u32>) {
if let Some(b) = val
&& let Some(c) = num {
&& b == c {
//~^ ERROR expected struct
//~| ERROR mismatched types
}
}
}
fn main() { } //~ ERROR this file contains an unclosed delimiter

View File

@ -0,0 +1,37 @@
error: this file contains an unclosed delimiter
--> $DIR/deli-ident-issue-1.rs:25:66
|
LL | impl dyn Demo {
| - unclosed delimiter
...
LL | c: u32| {
| - this delimiter might not be properly closed...
LL | a + b + c
LL | };
| - ...as it matches this but it has different indentation
...
LL | fn main() { }
| ^
error[E0574]: expected struct, variant or union type, found local variable `c`
--> $DIR/deli-ident-issue-1.rs:18:17
|
LL | && b == c {
| ^ not a struct, variant or union type
error[E0308]: mismatched types
--> $DIR/deli-ident-issue-1.rs:18:9
|
LL | fn check(&self, val: Option<u32>, num: Option<u32>) {
| - expected `()` because of default return type
...
LL | / && b == c {
LL | |
LL | |
LL | | }
| |_________^ expected `()`, found `bool`
error: aborting due to 3 previous errors
Some errors have detailed explanations: E0308, E0574.
For more information about an error, try `rustc --explain E0308`.

View File

@ -0,0 +1,7 @@
fn main() {
if 1 < 2 {
let _a = vec!]; //~ ERROR mismatched closing delimiter
}
} //~ ERROR unexpected closing delimiter
fn main() {}

View File

@ -0,0 +1,21 @@
error: unexpected closing delimiter: `}`
--> $DIR/deli-ident-issue-2.rs:5:1
|
LL | fn main() {
| - this opening brace...
...
LL | }
| - ...matches this closing brace
LL | }
| ^ unexpected closing delimiter
error: mismatched closing delimiter: `]`
--> $DIR/deli-ident-issue-2.rs:2:14
|
LL | if 1 < 2 {
| ^ unclosed delimiter
LL | let _a = vec!];
| ^ mismatched closing delimiter
error: aborting due to 2 previous errors

View File

@ -0,0 +1,12 @@
// This file has unexpected closing delimiter,
fn func(o: Option<u32>) {
match o {
Some(_x) => {} // Extra '}'
let _ = if true {};
}
None => {}
}
} //~ ERROR unexpected closing delimiter
fn main() {}

View File

@ -0,0 +1,11 @@
error: unexpected closing delimiter: `}`
--> $DIR/issue-68987-unmatch-issue-1.rs:10:1
|
LL | None => {}
| -- block is empty, you might have not meant to close it
LL | }
LL | }
| ^ unexpected closing delimiter
error: aborting due to previous error

View File

@ -0,0 +1,14 @@
// FIXME: this case need more work to fix
// currently the TokenTree matching ')' with '{', which is not user friendly for diagnostics
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

View File

@ -0,0 +1,21 @@
error: unexpected closing delimiter: `}`
--> $DIR/issue-68987-unmatch-issue-2.rs:14:1
|
LL | } else {
| - this opening brace...
LL |
LL | }
| - ...matches this closing brace
LL | }
| ^ unexpected closing delimiter
error: mismatched closing delimiter: `)`
--> $DIR/issue-68987-unmatch-issue-2.rs:3:32
|
LL | async fn obstest() -> Result<> {
| ^ unclosed delimiter
LL | let obs_connect = || -> Result<(), MyError) {
| ^ mismatched closing delimiter
error: aborting due to 2 previous errors

View File

@ -0,0 +1,8 @@
// the `{` is closed with `)`, there is a missing `(`
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

View File

@ -0,0 +1,21 @@
error: unexpected closing delimiter: `}`
--> $DIR/issue-68987-unmatch-issue-3.rs:8:1
|
LL | fn f(i: u32, j: u32) {
| - this opening brace...
...
LL | }
| - ...matches this closing brace
LL | }
| ^ unexpected closing delimiter
error: mismatched closing delimiter: `)`
--> $DIR/issue-68987-unmatch-issue-3.rs:5:19
|
LL | while cnt < j {
| ^ unclosed delimiter
LL | write!&mut res, " ");
| ^ mismatched closing delimiter
error: aborting due to 2 previous errors

View File

@ -0,0 +1,12 @@
// This file has unexpected closing delimiter,
fn func(o: Option<u32>) {
match o {
Some(_x) => // Missing '{'
let _ = if true {};
}
None => {}
}
} //~ ERROR unexpected closing delimiter
fn main() {}

View File

@ -0,0 +1,11 @@
error: unexpected closing delimiter: `}`
--> $DIR/issue-68987-unmatch-issue.rs:10:1
|
LL | None => {}
| -- block is empty, you might have not meant to close it
LL | }
LL | }
| ^ unexpected closing delimiter
error: aborting due to previous error

View File

@ -0,0 +1,3 @@
fn main() {}
fn f) {} //~ ERROR unexpected closing delimiter

View File

@ -0,0 +1,13 @@
error: unexpected closing delimiter: `)`
--> $DIR/issue-69259.rs:3:5
|
LL | fn main() {}
| -- ...matches this closing brace
| |
| this opening brace...
LL |
LL | fn f) {}
| ^ unexpected closing delimiter
error: aborting due to previous error