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_ast_passes | |
| 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_ast_passes')
| -rw-r--r-- | compiler/rustc_ast_passes/src/ast_validation.rs | 10 | ||||
| -rw-r--r-- | compiler/rustc_ast_passes/src/show_span.rs | 5 |
2 files changed, 6 insertions, 9 deletions
diff --git a/compiler/rustc_ast_passes/src/ast_validation.rs b/compiler/rustc_ast_passes/src/ast_validation.rs index eb7c75cac05..20caed1b230 100644 --- a/compiler/rustc_ast_passes/src/ast_validation.rs +++ b/compiler/rustc_ast_passes/src/ast_validation.rs @@ -482,9 +482,8 @@ impl<'a> AstValidator<'a> { } fn check_foreign_kind_bodyless(&self, ident: Ident, kind: &str, body: Option<Span>) { - let body = match body { - None => return, - Some(body) => body, + let Some(body) = body else { + return; }; self.err_handler() .struct_span_err(ident.span, &format!("incorrect `{}` inside `extern` block", kind)) @@ -504,9 +503,8 @@ impl<'a> AstValidator<'a> { /// An `fn` in `extern { ... }` cannot have a body `{ ... }`. fn check_foreign_fn_bodyless(&self, ident: Ident, body: Option<&Block>) { - let body = match body { - None => return, - Some(body) => body, + let Some(body) = body else { + return; }; self.err_handler() .struct_span_err(ident.span, "incorrect function inside `extern` block") diff --git a/compiler/rustc_ast_passes/src/show_span.rs b/compiler/rustc_ast_passes/src/show_span.rs index 6cef26a13e6..27637e311f4 100644 --- a/compiler/rustc_ast_passes/src/show_span.rs +++ b/compiler/rustc_ast_passes/src/show_span.rs @@ -57,9 +57,8 @@ impl<'a> Visitor<'a> for ShowSpanVisitor<'a> { } pub fn run(span_diagnostic: &rustc_errors::Handler, mode: &str, krate: &ast::Crate) { - let mode = match mode.parse().ok() { - Some(mode) => mode, - None => return, + let Ok(mode) = mode.parse() else { + return; }; let mut v = ShowSpanVisitor { span_diagnostic, mode }; visit::walk_crate(&mut v, krate); |
