about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-08-11 07:51:51 +0200
committerGitHub <noreply@github.com>2024-08-11 07:51:51 +0200
commit32e0fe129d495d3d4dacdcd066d9e339534a8338 (patch)
tree011962c5fbf99b4171d373e4adb0df9ff8760b52 /compiler/rustc_data_structures/src
parentbd7075c69e7472001cc31b9060849a6c7bc90d3e (diff)
parentc4c518d2d496774ecc7a368e826480d1928ed1ab (diff)
downloadrust-32e0fe129d495d3d4dacdcd066d9e339534a8338.tar.gz
rust-32e0fe129d495d3d4dacdcd066d9e339534a8338.zip
Rollup merge of #128762 - fmease:use-more-slice-pats, r=compiler-errors
Use more slice patterns inside the compiler

Nothing super noteworthy. Just replacing the common 'fragile' pattern of "length check followed by indexing or unwrap" with slice patterns for legibility and 'robustness'.

r? ghost
Diffstat (limited to 'compiler/rustc_data_structures/src')
-rw-r--r--compiler/rustc_data_structures/src/transitive_relation.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/compiler/rustc_data_structures/src/transitive_relation.rs b/compiler/rustc_data_structures/src/transitive_relation.rs
index 26b00e0af3a..e81ebb9a4be 100644
--- a/compiler/rustc_data_structures/src/transitive_relation.rs
+++ b/compiler/rustc_data_structures/src/transitive_relation.rs
@@ -203,9 +203,9 @@ impl<T: Eq + Hash + Copy> TransitiveRelation<T> {
     /// exists). See `postdom_upper_bound` for details.
     pub fn mutual_immediate_postdominator(&self, mut mubs: Vec<T>) -> Option<T> {
         loop {
-            match mubs.len() {
-                0 => return None,
-                1 => return Some(mubs[0]),
+            match mubs[..] {
+                [] => return None,
+                [mub] => return Some(mub),
                 _ => {
                     let m = mubs.pop().unwrap();
                     let n = mubs.pop().unwrap();