Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix two ICEs in the parser #86010

Merged
merged 2 commits into from
Jun 7, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Remove incorrect assertion in type parsing code
  • Loading branch information
FabianWolff committed Jun 4, 2021
commit 4e219e6335a04cae15a784063f8cbe021076c933
1 change: 0 additions & 1 deletion compiler/rustc_parse/src/parser/ty.rs
Original file line number Diff line number Diff line change
@@ -334,7 +334,6 @@ impl<'a> Parser<'a> {
mut bounds: GenericBounds,
plus: bool,
) -> PResult<'a, TyKind> {
assert_ne!(self.token, token::Question);
if plus {
self.eat_plus(); // `+`, or `+=` gets split and `+` is discarded
bounds.append(&mut self.parse_generic_bounds(Some(self.prev_token.span))?);
4 changes: 4 additions & 0 deletions src/test/ui/parser/issue-84148-1.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn f(t:for<>t?)
//~^ ERROR: expected parameter name
//~| ERROR: expected one of
//~| ERROR: expected one of
23 changes: 23 additions & 0 deletions src/test/ui/parser/issue-84148-1.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
error: expected parameter name, found `?`
--> $DIR/issue-84148-1.rs:1:14
|
LL | fn f(t:for<>t?)
| ^ expected parameter name

error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
--> $DIR/issue-84148-1.rs:1:14
|
LL | fn f(t:for<>t?)
| ^
| |
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
| help: missing `,`

error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
--> $DIR/issue-84148-1.rs:1:15
|
LL | fn f(t:for<>t?)
| ^ expected one of `->`, `;`, `where`, or `{`

error: aborting due to 3 previous errors

4 changes: 4 additions & 0 deletions src/test/ui/parser/issue-84148-2.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// error-pattern: this file contains an unclosed delimiter
// error-pattern: expected parameter name
// error-pattern: expected one of
fn f(t:for<>t?
31 changes: 31 additions & 0 deletions src/test/ui/parser/issue-84148-2.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
error: this file contains an unclosed delimiter
--> $DIR/issue-84148-2.rs:4:16
|
LL | fn f(t:for<>t?
| - ^
| |
| unclosed delimiter

error: expected parameter name, found `?`
--> $DIR/issue-84148-2.rs:4:14
|
LL | fn f(t:for<>t?
| ^ expected parameter name

error: expected one of `(`, `)`, `+`, `,`, `::`, or `<`, found `?`
--> $DIR/issue-84148-2.rs:4:14
|
LL | fn f(t:for<>t?
| ^
| |
| expected one of `(`, `)`, `+`, `,`, `::`, or `<`
| help: missing `,`

error: expected one of `->`, `;`, `where`, or `{`, found `<eof>`
--> $DIR/issue-84148-2.rs:4:16
|
LL | fn f(t:for<>t?
| ^ expected one of `->`, `;`, `where`, or `{`

error: aborting due to 4 previous errors