Rollup merge of #119359 - DaniPopes:ident-or-err, r=compiler-errors
Simplify Parser::ident_or_error Avoid a nested `Result<T, PResult<T>>`.
This commit is contained in:
commit
54bcb07ab1
1 changed files with 4 additions and 12 deletions
|
@ -504,18 +504,10 @@ impl<'a> Parser<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ident_or_err(&mut self, recover: bool) -> PResult<'a, (Ident, /* is_raw */ bool)> {
|
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));
|
match self.token.ident() {
|
||||||
|
Some(ident) => Ok(ident),
|
||||||
let (ident, is_raw) = match result {
|
None => self.expected_ident_found(recover),
|
||||||
Ok(ident) => ident,
|
}
|
||||||
Err(err) => match err {
|
|
||||||
// we recovered!
|
|
||||||
Ok(ident) => ident,
|
|
||||||
Err(err) => return Err(err),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok((ident, is_raw))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Checks if the next token is `tok`, and returns `true` if so.
|
/// Checks if the next token is `tok`, and returns `true` if so.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue