diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-02-20 00:37:34 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-20 00:37:34 +0100 |
| commit | f2d6770f779051f1f5a28451b68784d2103bca32 (patch) | |
| tree | 90ba27b14c38a8ff603d9aef8642a16b58a7f52d /compiler/rustc_parse/src/parser | |
| parent | 7ca1c48bbb6d300bda665a59b7ad226bc71e7be9 (diff) | |
| parent | 2ef8af66196f7cc270a0532ea989f2fc6bc6885d (diff) | |
| download | rust-f2d6770f779051f1f5a28451b68784d2103bca32.tar.gz rust-f2d6770f779051f1f5a28451b68784d2103bca32.zip | |
Rollup merge of #94146 - est31:let_else, r=cjgillot
Adopt let else in more places Continuation of #89933, #91018, #91481, #93046, #93590, #94011. I have extended my clippy lint to also recognize tuple passing and match statements. The diff caused by fixing it is way above 1 thousand lines. Thus, I split it up into multiple pull requests to make reviewing easier. This is the biggest of these PRs and handles the changes outside of rustdoc, rustc_typeck, rustc_const_eval, rustc_trait_selection, which were handled in PRs #94139, #94142, #94143, #94144.
Diffstat (limited to 'compiler/rustc_parse/src/parser')
| -rw-r--r-- | compiler/rustc_parse/src/parser/expr.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/item.rs | 5 | ||||
| -rw-r--r-- | compiler/rustc_parse/src/parser/stmt.rs | 5 |
3 files changed, 6 insertions, 9 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs index e9aa4adcaf7..7cb8c35b868 100644 --- a/compiler/rustc_parse/src/parser/expr.rs +++ b/compiler/rustc_parse/src/parser/expr.rs @@ -1667,9 +1667,8 @@ impl<'a> Parser<'a> { Err(LitError::NotLiteral) => None, Err(err) => { let span = token.span; - let lit = match token.kind { - token::Literal(lit) => lit, - _ => unreachable!(), + let token::Literal(lit) = token.kind else { + unreachable!(); }; self.bump(); self.report_lit_error(err, lit, span); diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs index 93f5d79c0db..20ca8a99ab7 100644 --- a/compiler/rustc_parse/src/parser/item.rs +++ b/compiler/rustc_parse/src/parser/item.rs @@ -439,9 +439,8 @@ impl<'a> Parser<'a> { /// Recover if we parsed attributes and expected an item but there was none. fn recover_attrs_no_item(&mut self, attrs: &[Attribute]) -> PResult<'a, ()> { - let (start, end) = match attrs { - [] => return Ok(()), - [x0 @ xn] | [x0, .., xn] => (x0, xn), + let ([start @ end] | [start, .., end]) = attrs else { + return Ok(()); }; let msg = if end.is_doc_comment() { "expected item after doc comment" diff --git a/compiler/rustc_parse/src/parser/stmt.rs b/compiler/rustc_parse/src/parser/stmt.rs index d3e7d1690cc..227a9e37dbc 100644 --- a/compiler/rustc_parse/src/parser/stmt.rs +++ b/compiler/rustc_parse/src/parser/stmt.rs @@ -524,9 +524,8 @@ impl<'a> Parser<'a> { // Skip looking for a trailing semicolon when we have an interpolated statement. maybe_whole!(self, NtStmt, |x| Some(x)); - let mut stmt = match self.parse_stmt_without_recovery(true, ForceCollect::No)? { - Some(stmt) => stmt, - None => return Ok(None), + let Some(mut stmt) = self.parse_stmt_without_recovery(true, ForceCollect::No)? else { + return Ok(None); }; let mut eat_semi = true; |
