diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2023-12-28 18:48:01 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-12-28 18:48:01 +0100 |
| commit | 54bcb07ab1aa5b0fb0fe68ccc23e8e260472b834 (patch) | |
| tree | 1cbaa5598d87644525f8a4ea0232d42032a360b6 /compiler/rustc_parse/src | |
| parent | 2f51bad66b218afd87cf24f2412721481302faf9 (diff) | |
| parent | 826269eddb0488bf4e687778cde27726f7148eb9 (diff) | |
| download | rust-54bcb07ab1aa5b0fb0fe68ccc23e8e260472b834.tar.gz rust-54bcb07ab1aa5b0fb0fe68ccc23e8e260472b834.zip | |
Rollup merge of #119359 - DaniPopes:ident-or-err, r=compiler-errors
Simplify Parser::ident_or_error Avoid a nested `Result<T, PResult<T>>`.
Diffstat (limited to 'compiler/rustc_parse/src')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 1598fd19f6d..9c24d87af9a 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -504,18 +504,10 @@ impl<'a> Parser<'a> { } fn ident_or_err(&mut self, recover: bool) -> PResult<'a, (Ident, /* is_raw */ bool)> { - let result = self.token.ident().ok_or_else(|| self.expected_ident_found(recover)); - - let (ident, is_raw) = match result { - Ok(ident) => ident, - Err(err) => match err { - // we recovered! - Ok(ident) => ident, - Err(err) => return Err(err), - }, - }; - - Ok((ident, is_raw)) + match self.token.ident() { + Some(ident) => Ok(ident), + None => self.expected_ident_found(recover), + } } /// Checks if the next token is `tok`, and returns `true` if so. |
