Skip to content

Commit 62ded07

Browse files
committed
cancel a not emitted error after parsing const generic args
1 parent 2d15732 commit 62ded07

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

compiler/rustc_parse/src/parser/path.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -630,10 +630,14 @@ impl<'a> Parser<'a> {
630630
Ok(ty) => GenericArg::Type(ty),
631631
Err(err) => {
632632
if is_const_fn {
633-
if let Ok(expr) = (*snapshot).parse_expr_res(Restrictions::CONST_EXPR, None)
634-
{
635-
self.restore_snapshot(snapshot);
636-
return Ok(Some(self.dummy_const_arg_needs_braces(err, expr.span)));
633+
match (*snapshot).parse_expr_res(Restrictions::CONST_EXPR, None) {
634+
Ok(expr) => {
635+
self.restore_snapshot(snapshot);
636+
return Ok(Some(self.dummy_const_arg_needs_braces(err, expr.span)));
637+
}
638+
Err(err) => {
639+
err.cancel();
640+
}
637641
}
638642
}
639643
// Try to recover from possible `const` arg without braces.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// #95163
2+
fn return_ty() -> impl Into<<() as Reexported;
3+
//~^ ERROR expected one of `(`, `::`, `<`, or `>`, found `;`
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
error: expected one of `(`, `::`, `<`, or `>`, found `;`
2+
--> $DIR/ice-const-generic-function-return-ty.rs:2:46
3+
|
4+
LL | fn return_ty() -> impl Into<<() as Reexported;
5+
| ^ expected one of `(`, `::`, `<`, or `>`
6+
7+
error: aborting due to previous error
8+

0 commit comments

Comments
 (0)