Skip to content

Commit 131d48f

Browse files
authored
Rollup merge of #125279 - WaffleLapkin:unpacktermindebug, r=aDotInTheVoid,Nilstrieb,BoxyUwU
make `Debug` impl for `Term` simpler meow
2 parents c5b8c7c + 006866f commit 131d48f

File tree

1 file changed

+4
-8
lines changed
  • compiler/rustc_middle/src/ty

1 file changed

+4
-8
lines changed

compiler/rustc_middle/src/ty/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,10 @@ unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync
536536

537537
impl Debug for Term<'_> {
538538
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
539-
let data = if let Some(ty) = self.ty() {
540-
format!("Term::Ty({ty:?})")
541-
} else if let Some(ct) = self.ct() {
542-
format!("Term::Ct({ct:?})")
543-
} else {
544-
unreachable!()
545-
};
546-
f.write_str(&data)
539+
match self.unpack() {
540+
TermKind::Ty(ty) => write!(f, "Term::Ty({ty:?})"),
541+
TermKind::Const(ct) => write!(f, "Term::Const({ct:?})"),
542+
}
547543
}
548544
}
549545

0 commit comments

Comments
 (0)