diff options
| author | bors <bors@rust-lang.org> | 2024-03-20 09:37:39 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-03-20 09:37:39 +0000 |
| commit | 0f706af330022b46efb5bcc8da7ad7276dfdeb69 (patch) | |
| tree | c2dbee18d83faf4b78a8e577924dc5a7958aa122 /compiler/rustc_parse/src/parser/mod.rs | |
| parent | b7dcabe55e3b915ba9488dc374f752404c2c8945 (diff) | |
| parent | 53a753e31f87280abaf342f2e235366901716ea5 (diff) | |
| download | rust-0f706af330022b46efb5bcc8da7ad7276dfdeb69.tar.gz rust-0f706af330022b46efb5bcc8da7ad7276dfdeb69.zip | |
Auto merge of #122763 - matthiaskrgr:rollup-o8a2mye, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #121543 (various clippy fixes) - #122540 (Do not use `?`-induced skewing of type inference in the compiler) - #122730 (Expose `ucred::peer_cred` on QNX targets to enable dist builds) - #122732 (Remove redundant coroutine captures note) - #122739 (Add "put" as a confusable for insert on hash map/set) - #122748 (Reduce `pub` usage in `rustc_session`.) r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_parse/src/parser/mod.rs')
| -rw-r--r-- | compiler/rustc_parse/src/parser/mod.rs | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/rustc_parse/src/parser/mod.rs b/compiler/rustc_parse/src/parser/mod.rs index 12879dc429b..125e77d8ee7 100644 --- a/compiler/rustc_parse/src/parser/mod.rs +++ b/compiler/rustc_parse/src/parser/mod.rs @@ -465,7 +465,9 @@ impl<'a> Parser<'a> { matches!(self.recovery, Recovery::Allowed) } - pub fn unexpected<T>(&mut self) -> PResult<'a, T> { + /// Version of [`unexpected`](Parser::unexpected) that "returns" any type in the `Ok` + /// (both those functions never return "Ok", and so can lie like that in the type). + pub fn unexpected_any<T>(&mut self) -> PResult<'a, T> { match self.expect_one_of(&[], &[]) { Err(e) => Err(e), // We can get `Ok(true)` from `recover_closing_delimiter` @@ -474,6 +476,10 @@ impl<'a> Parser<'a> { } } + pub fn unexpected(&mut self) -> PResult<'a, ()> { + self.unexpected_any() + } + /// Expects and consumes the token `t`. Signals an error if the next token is not `t`. pub fn expect(&mut self, t: &TokenKind) -> PResult<'a, Recovered> { if self.expected_tokens.is_empty() { @@ -1278,7 +1284,11 @@ impl<'a> Parser<'a> { } fn parse_delim_args(&mut self) -> PResult<'a, P<DelimArgs>> { - if let Some(args) = self.parse_delim_args_inner() { Ok(P(args)) } else { self.unexpected() } + if let Some(args) = self.parse_delim_args_inner() { + Ok(P(args)) + } else { + self.unexpected_any() + } } fn parse_attr_args(&mut self) -> PResult<'a, AttrArgs> { |
