Skip to content

Commit 4e219e6

Browse files
committed
Remove incorrect assertion in type parsing code
1 parent c4c2ab5 commit 4e219e6

File tree

5 files changed

+62
-1
lines changed

5 files changed

+62
-1
lines changed

compiler/rustc_parse/src/parser/ty.rs

-1
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,6 @@ impl<'a> Parser<'a> {
334334
mut bounds: GenericBounds,
335335
plus: bool,
336336
) -> PResult<'a, TyKind> {
337-
assert_ne!(self.token, token::Question);
338337
if plus {
339338
self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded
340339
bounds.append(&mut self.parse_generic_bounds(Some(self.prev_token.span))?);

src/test/ui/parser/issue-84148-1.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
fn f(t:for<>t?)
2+
//~^ ERROR: expected parameter name
3+
//~| ERROR: expected one of
4+
//~| ERROR: expected one of
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error: expected parameter name, found `?`
2+
--> $DIR/issue-84148-1.rs:1:14
3+
|
4+
LL | fn f(t:for<>t?)
5+
| ^ expected parameter name
6+
7+
error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
8+
--> $DIR/issue-84148-1.rs:1:14
9+
|
10+
LL | fn f(t:for<>t?)
11+
| ^
12+
| |
13+
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
14+
| help: missing `,`
15+
16+
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
17+
--> $DIR/issue-84148-1.rs:1:15
18+
|
19+
LL | fn f(t:for<>t?)
20+
| ^ expected one of `->`, `;`, `where`, or `{`
21+
22+
error: aborting due to 3 previous errors
23+

src/test/ui/parser/issue-84148-2.rs

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// error-pattern: this file contains an unclosed delimiter
2+
// error-pattern: expected parameter name
3+
// error-pattern: expected one of
4+
fn f(t:for<>t?
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
error: this file contains an unclosed delimiter
2+
--> $DIR/issue-84148-2.rs:4:16
3+
|
4+
LL | fn f(t:for<>t?
5+
| - ^
6+
| |
7+
| unclosed delimiter
8+
9+
error: expected parameter name, found `?`
10+
--> $DIR/issue-84148-2.rs:4:14
11+
|
12+
LL | fn f(t:for<>t?
13+
| ^ expected parameter name
14+
15+
error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
16+
--> $DIR/issue-84148-2.rs:4:14
17+
|
18+
LL | fn f(t:for<>t?
19+
| ^
20+
| |
21+
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
22+
| help: missing `,`
23+
24+
error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
25+
--> $DIR/issue-84148-2.rs:4:16
26+
|
27+
LL | fn f(t:for<>t?
28+
| ^ expected one of `->`, `;`, `where`, or `{`
29+
30+
error: aborting due to 4 previous errors
31+

0 commit comments

Comments
 (0)