Skip to content

Commit

Permalink
Rollup merge of #95200 - TaKO8Ki:cancel-not-emitted-error-when-parsin…
Browse files Browse the repository at this point in the history
…g-generic-arg, r=oli-obk

Cancel a not emitted error after parsing const generic args

closes #95163
  • Loading branch information
Dylan-DPC committed Mar 22, 2022
2 parents 0e80a7a + 62ded07 commit 5d3dfb4
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
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

0 comments on commit 5d3dfb4

Please sign in to comment.