about summary refs log tree commit diff
path: root/compiler/rustc_parse/src
diff options
context:
space:
mode:
authorDaniPopes <57450786+DaniPopes@users.noreply.github.com>2023-12-27 21:16:29 +0100
committerDaniPopes <57450786+DaniPopes@users.noreply.github.com>2023-12-27 21:18:32 +0100
commit826269eddb0488bf4e687778cde27726f7148eb9 (patch)
treef756b5a3f35be49a3157bffc9c1fe700fc7fe17f /compiler/rustc_parse/src
parenta861c8965eaff66901710cc384a59f6b0b1a7700 (diff)
downloadrust-826269eddb0488bf4e687778cde27726f7148eb9.tar.gz
rust-826269eddb0488bf4e687778cde27726f7148eb9.zip
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.rs16
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.