diff options
| author | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-03-22 16:06:56 +0900 |
|---|---|---|
| committer | Takayuki Maeda <takoyaki0316@gmail.com> | 2022-03-22 16:06:56 +0900 |
| commit | 62ded071d588b92b394c4561d19d517d87074728 (patch) | |
| tree | 78d90dbda76cadc33f9ed5a5e4507e2f389ac062 /compiler/rustc_parse/src/parser | |
| parent | 2d15732f6eec3d50ed1ad4a79c36b07d8b896474 (diff) | |
| download | rust-62ded071d588b92b394c4561d19d517d87074728.tar.gz rust-62ded071d588b92b394c4561d19d517d87074728.zip | |
cancel a not emitted error after parsing const generic args
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/path.rs | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/path.rs b/compiler/rustc_parse/src/parser/path.rs index 17c57867cf9..07ce879de8f 100644 --- a/compiler/rustc_parse/src/parser/path.rs +++ b/compiler/rustc_parse/src/parser/path.rs @@ -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. |
