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

Cancel a not emitted error after parsing const generic args #95200

Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 8 additions & 4 deletions compiler/rustc_parse/src/parser/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -630,10 +630,14 @@ impl<'a> Parser<'a> {
Ok(ty) => GenericArg::Type(ty),
Err(err) => {
if is_const_fn {
if let Ok(expr) = (*snapshot).parse_expr_res(Restrictions::CONST_EXPR, None)
{
self.restore_snapshot(snapshot);
return Ok(Some(self.dummy_const_arg_needs_braces(err, expr.span)));
match (*snapshot).parse_expr_res(Restrictions::CONST_EXPR, None) {
Ok(expr) => {
self.restore_snapshot(snapshot);
return Ok(Some(self.dummy_const_arg_needs_braces(err, expr.span)));
}
Err(err) => {
err.cancel();
}
}
}
// Try to recover from possible `const` arg without braces.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// #95163
fn return_ty() -> impl Into<<() as Reexported;
//~^ ERROR expected one of `(`, `::`, `<`, or `>`, found `;`

fn main() {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
error: expected one of `(`, `::`, `<`, or `>`, found `;`
--> $DIR/ice-const-generic-function-return-ty.rs:2:46
|
LL | fn return_ty() -> impl Into<<() as Reexported;
| ^ expected one of `(`, `::`, `<`, or `>`

error: aborting due to previous error