]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_type_ir/src/sty.rs
Rollup merge of #105109 - rcvalle:rust-kcfi, r=bjorn3
[rust.git] / compiler / rustc_type_ir / src / sty.rs
index a6537f41d1e560bc2bc86c2ef3e54b09b9251447..3ed616d709b1edf4e1b38933c8002417eea0fb67 100644 (file)
@@ -330,7 +330,14 @@ fn eq(&self, other: &TyKind<I>) -> bool {
                 (Placeholder(a_p), Placeholder(b_p)) => a_p == b_p,
                 (Infer(a_t), Infer(b_t)) => a_t == b_t,
                 (Error(a_e), Error(b_e)) => a_e == b_e,
-                _ => true, // unreachable
+                (Bool, Bool) | (Char, Char) | (Str, Str) | (Never, Never) => true,
+                _ => {
+                    debug_assert!(
+                        false,
+                        "This branch must be unreachable, maybe the match is missing an arm? self = self = {self:?}, other = {other:?}"
+                    );
+                    true
+                }
             }
     }
 }
@@ -381,7 +388,11 @@ fn cmp(&self, other: &TyKind<I>) -> Ordering {
                 (Placeholder(a_p), Placeholder(b_p)) => a_p.cmp(b_p),
                 (Infer(a_t), Infer(b_t)) => a_t.cmp(b_t),
                 (Error(a_e), Error(b_e)) => a_e.cmp(b_e),
-                _ => Ordering::Equal, // unreachable
+                (Bool, Bool) | (Char, Char) | (Str, Str) | (Never, Never) => Ordering::Equal,
+                _ => {
+                    debug_assert!(false, "This branch must be unreachable, maybe the match is missing an arm? self = self = {self:?}, other = {other:?}");
+                    Ordering::Equal
+                }
             }
         })
     }
@@ -977,7 +988,13 @@ fn eq(&self, other: &RegionKind<I>) -> bool {
                 (ReVar(a_r), ReVar(b_r)) => a_r == b_r,
                 (RePlaceholder(a_r), RePlaceholder(b_r)) => a_r == b_r,
                 (ReErased, ReErased) => true,
-                _ => true, // unreachable
+                _ => {
+                    debug_assert!(
+                        false,
+                        "This branch must be unreachable, maybe the match is missing an arm? self = self = {self:?}, other = {other:?}"
+                    );
+                    true
+                }
             }
     }
 }
@@ -1008,7 +1025,10 @@ fn cmp(&self, other: &RegionKind<I>) -> Ordering {
                 (ReVar(a_r), ReVar(b_r)) => a_r.cmp(b_r),
                 (RePlaceholder(a_r), RePlaceholder(b_r)) => a_r.cmp(b_r),
                 (ReErased, ReErased) => Ordering::Equal,
-                _ => Ordering::Equal, // unreachable
+                _ => {
+                    debug_assert!(false, "This branch must be unreachable, maybe the match is missing an arm? self = self = {self:?}, other = {other:?}");
+                    Ordering::Equal
+                }
             }
         })
     }