diff --git a/compiler/rustc_type_ir/src/sty.rs b/compiler/rustc_type_ir/src/sty.rs index a6537f41d1e..3ed616d709b 100644 --- a/compiler/rustc_type_ir/src/sty.rs +++ b/compiler/rustc_type_ir/src/sty.rs @@ -330,7 +330,14 @@ impl PartialEq for TyKind { (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 @@ impl Ord for TyKind { (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 @@ impl PartialEq for RegionKind { (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 @@ impl Ord for RegionKind { (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 + } } }) }