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.
This commit is contained in:
Matthias Krüger
2022-02-20 00:37:34 +01:00
committed by GitHub
132 changed files with 539 additions and 881 deletions

View File

@@ -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);

View File

@@ -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"

View File

@@ -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;