Skip to content

Commit c4d00d7

Browse files
committed
add testcase for #104012
1 parent 1f72129 commit c4d00d7

14 files changed

+216
-0
lines changed

tests/ui/parser/deli-ident-issue-1.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
// error-pattern: this file contains an unclosed delimiter
2+
#![feature(let_chains)]
3+
trait Demo {}
4+
5+
impl dyn Demo {
6+
pub fn report(&self) -> u32 {
7+
let sum = |a: u32,
8+
b: u32,
9+
c: u32| {
10+
a + b + c
11+
};
12+
sum(1, 2, 3)
13+
}
14+
15+
fn check(&self, val: Option<u32>, num: Option<u32>) {
16+
if let Some(b) = val
17+
&& let Some(c) = num {
18+
&& b == c {
19+
//~^ ERROR expected struct
20+
//~| ERROR mismatched types
21+
}
22+
}
23+
}
24+
25+
fn main() { } //~ ERROR this file contains an unclosed delimiter
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
error: this file contains an unclosed delimiter
2+
--> $DIR/deli-ident-issue-1.rs:25:66
3+
|
4+
LL | impl dyn Demo {
5+
| - unclosed delimiter
6+
...
7+
LL | c: u32| {
8+
| - this delimiter might not be properly closed...
9+
LL | a + b + c
10+
LL | };
11+
| - ...as it matches this but it has different indentation
12+
...
13+
LL | fn main() { }
14+
| ^
15+
16+
error[E0574]: expected struct, variant or union type, found local variable `c`
17+
--> $DIR/deli-ident-issue-1.rs:18:17
18+
|
19+
LL | && b == c {
20+
| ^ not a struct, variant or union type
21+
22+
error[E0308]: mismatched types
23+
--> $DIR/deli-ident-issue-1.rs:18:9
24+
|
25+
LL | fn check(&self, val: Option<u32>, num: Option<u32>) {
26+
| - expected `()` because of default return type
27+
...
28+
LL | / && b == c {
29+
LL | |
30+
LL | |
31+
LL | | }
32+
| |_________^ expected `()`, found `bool`
33+
34+
error: aborting due to 3 previous errors
35+
36+
Some errors have detailed explanations: E0308, E0574.
37+
For more information about an error, try `rustc --explain E0308`.

tests/ui/parser/deli-ident-issue-2.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn main() {
2+
if 1 < 2 {
3+
let _a = vec!]; //~ ERROR mismatched closing delimiter
4+
}
5+
} //~ ERROR unexpected closing delimiter
6+
7+
fn main() {}
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: unexpected closing delimiter: `}`
2+
--> $DIR/deli-ident-issue-2.rs:5:1
3+
|
4+
LL | fn main() {
5+
| - this opening brace...
6+
...
7+
LL | }
8+
| - ...matches this closing brace
9+
LL | }
10+
| ^ unexpected closing delimiter
11+
12+
error: mismatched closing delimiter: `]`
13+
--> $DIR/deli-ident-issue-2.rs:2:14
14+
|
15+
LL | if 1 < 2 {
16+
| ^ unclosed delimiter
17+
LL | let _a = vec!];
18+
| ^ mismatched closing delimiter
19+
20+
error: aborting due to 2 previous errors
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file has unexpected closing delimiter,
2+
3+
fn func(o: Option<u32>) {
4+
match o {
5+
Some(_x) => {} // Extra '}'
6+
let _ = if true {};
7+
}
8+
None => {}
9+
}
10+
} //~ ERROR unexpected closing delimiter
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: unexpected closing delimiter: `}`
2+
--> $DIR/issue-68987-unmatch-issue-1.rs:10:1
3+
|
4+
LL | None => {}
5+
| -- block is empty, you might have not meant to close it
6+
LL | }
7+
LL | }
8+
| ^ unexpected closing delimiter
9+
10+
error: aborting due to previous error
11+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
// FIXME: this case need more work to fix
2+
// currently the TokenTree matching ')' with '{', which is not user friendly for diagnostics
3+
async fn obstest() -> Result<> {
4+
let obs_connect = || -> Result<(), MyError) { //~ ERROR mismatched closing delimiter
5+
async {
6+
}
7+
}
8+
9+
if let Ok(version, scene_list) = obs_connect() {
10+
11+
} else {
12+
13+
}
14+
} //~ ERROR unexpected closing delimiter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: unexpected closing delimiter: `}`
2+
--> $DIR/issue-68987-unmatch-issue-2.rs:14:1
3+
|
4+
LL | } else {
5+
| - this opening brace...
6+
LL |
7+
LL | }
8+
| - ...matches this closing brace
9+
LL | }
10+
| ^ unexpected closing delimiter
11+
12+
error: mismatched closing delimiter: `)`
13+
--> $DIR/issue-68987-unmatch-issue-2.rs:3:32
14+
|
15+
LL | async fn obstest() -> Result<> {
16+
| ^ unclosed delimiter
17+
LL | let obs_connect = || -> Result<(), MyError) {
18+
| ^ mismatched closing delimiter
19+
20+
error: aborting due to 2 previous errors
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// the `{` is closed with `)`, there is a missing `(`
2+
fn f(i: u32, j: u32) {
3+
let res = String::new();
4+
let mut cnt = i;
5+
while cnt < j {
6+
write!&mut res, " "); //~ ERROR mismatched closing delimiter
7+
}
8+
} //~ ERROR unexpected closing delimiter
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error: unexpected closing delimiter: `}`
2+
--> $DIR/issue-68987-unmatch-issue-3.rs:8:1
3+
|
4+
LL | fn f(i: u32, j: u32) {
5+
| - this opening brace...
6+
...
7+
LL | }
8+
| - ...matches this closing brace
9+
LL | }
10+
| ^ unexpected closing delimiter
11+
12+
error: mismatched closing delimiter: `)`
13+
--> $DIR/issue-68987-unmatch-issue-3.rs:5:19
14+
|
15+
LL | while cnt < j {
16+
| ^ unclosed delimiter
17+
LL | write!&mut res, " ");
18+
| ^ mismatched closing delimiter
19+
20+
error: aborting due to 2 previous errors
21+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// This file has unexpected closing delimiter,
2+
3+
fn func(o: Option<u32>) {
4+
match o {
5+
Some(_x) => // Missing '{'
6+
let _ = if true {};
7+
}
8+
None => {}
9+
}
10+
} //~ ERROR unexpected closing delimiter
11+
12+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error: unexpected closing delimiter: `}`
2+
--> $DIR/issue-68987-unmatch-issue.rs:10:1
3+
|
4+
LL | None => {}
5+
| -- block is empty, you might have not meant to close it
6+
LL | }
7+
LL | }
8+
| ^ unexpected closing delimiter
9+
10+
error: aborting due to previous error
11+

tests/ui/parser/issues/issue-69259.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {}
2+
3+
fn f) {} //~ ERROR unexpected closing delimiter
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
error: unexpected closing delimiter: `)`
2+
--> $DIR/issue-69259.rs:3:5
3+
|
4+
LL | fn main() {}
5+
| -- ...matches this closing brace
6+
| |
7+
| this opening brace...
8+
LL |
9+
LL | fn f) {}
10+
| ^ unexpected closing delimiter
11+
12+
error: aborting due to previous error
13+

0 commit comments

Comments
 (0)