about summary refs log tree commit diff
path: root/compiler/rustc_data_structures
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2022-02-20 00:37:34 +0100
committerGitHub <noreply@github.com>2022-02-20 00:37:34 +0100
commitf2d6770f779051f1f5a28451b68784d2103bca32 (patch)
tree90ba27b14c38a8ff603d9aef8642a16b58a7f52d /compiler/rustc_data_structures
parent7ca1c48bbb6d300bda665a59b7ad226bc71e7be9 (diff)
parent2ef8af66196f7cc270a0532ea989f2fc6bc6885d (diff)
downloadrust-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_data_structures')
-rw-r--r--compiler/rustc_data_structures/src/binary_search_util/mod.rs5
-rw-r--r--compiler/rustc_data_structures/src/lib.rs1
-rw-r--r--compiler/rustc_data_structures/src/transitive_relation.rs12
3 files changed, 7 insertions, 11 deletions
diff --git a/compiler/rustc_data_structures/src/binary_search_util/mod.rs b/compiler/rustc_data_structures/src/binary_search_util/mod.rs
index bf09b2f8eef..d40172a2e2f 100644
--- a/compiler/rustc_data_structures/src/binary_search_util/mod.rs
+++ b/compiler/rustc_data_structures/src/binary_search_util/mod.rs
@@ -10,9 +10,8 @@ pub fn binary_search_slice<'d, E, K>(data: &'d [E], key_fn: impl Fn(&E) -> K, ke
 where
     K: Ord,
 {
-    let mid = match data.binary_search_by_key(key, &key_fn) {
-        Ok(mid) => mid,
-        Err(_) => return &[],
+    let Ok(mid) = data.binary_search_by_key(key, &key_fn) else {
+        return &[];
     };
     let size = data.len();
 
diff --git a/compiler/rustc_data_structures/src/lib.rs b/compiler/rustc_data_structures/src/lib.rs
index 80f83140f4b..ea02a73c422 100644
--- a/compiler/rustc_data_structures/src/lib.rs
+++ b/compiler/rustc_data_structures/src/lib.rs
@@ -14,6 +14,7 @@
 #![feature(control_flow_enum)]
 #![feature(core_intrinsics)]
 #![feature(extend_one)]
+#![feature(let_else)]
 #![feature(hash_raw_entry)]
 #![feature(maybe_uninit_uninit_array)]
 #![feature(min_specialization)]
diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs
index ccf8bd69ebd..0af571610fe 100644
--- a/compiler/rustc_data_structures/src/transitive_relation.rs
+++ b/compiler/rustc_data_structures/src/transitive_relation.rs
@@ -190,11 +190,8 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
     ///
     /// Note that this set can, in principle, have any size.
     pub fn minimal_upper_bounds(&self, a: &T, b: &T) -> Vec<&T> {
-        let (mut a, mut b) = match (self.index(a), self.index(b)) {
-            (Some(a), Some(b)) => (a, b),
-            (None, _) | (_, None) => {
-                return vec![];
-            }
+        let (Some(mut a), Some(mut b)) = (self.index(a), self.index(b)) else {
+            return vec![];
         };
 
         // in some cases, there are some arbitrary choices to be made;
@@ -294,9 +291,8 @@ impl<T: Eq + Hash> TransitiveRelation<T> {
     /// then `parents(a)` returns `[b, c]`. The `postdom_parent` function
     /// would further reduce this to just `f`.
     pub fn parents(&self, a: &T) -> Vec<&T> {
-        let a = match self.index(a) {
-            Some(a) => a,
-            None => return vec![],
+        let Some(a) = self.index(a) else {
+            return vec![];
         };
 
         // Steal the algorithm for `minimal_upper_bounds` above, but