about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEllen <supbscripter@gmail.com>2022-09-08 21:09:23 +0100
committerEllen <supbscripter@gmail.com>2022-09-08 21:09:23 +0100
commitef36af2f9d44b8b57660e6b6eea227e1e99bcf2b (patch)
tree3eade170b60a6cc498e6f71682f23dd865ca5b16
parent87788097b776f8e3662f76627944230684b671bd (diff)
downloadrust-ef36af2f9d44b8b57660e6b6eea227e1e99bcf2b.tar.gz
rust-ef36af2f9d44b8b57660e6b6eea227e1e99bcf2b.zip
ptr: 43276834268743978
-rw-r--r--compiler/rustc_middle/src/ty/mod.rs15
1 files changed, 14 insertions, 1 deletions
diff --git a/compiler/rustc_middle/src/ty/mod.rs b/compiler/rustc_middle/src/ty/mod.rs
index 37136ff2ef5..4635a9d5575 100644
--- a/compiler/rustc_middle/src/ty/mod.rs
+++ b/compiler/rustc_middle/src/ty/mod.rs
@@ -915,12 +915,25 @@ pub struct CoercePredicate<'tcx> {
 }
 pub type PolyCoercePredicate<'tcx> = ty::Binder<'tcx, CoercePredicate<'tcx>>;
 
-#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
 pub struct Term<'tcx> {
     ptr: NonZeroUsize,
     marker: PhantomData<(Ty<'tcx>, Const<'tcx>)>,
 }
 
+impl Debug for Term<'_> {
+    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+        let data = if let Some(ty) = self.ty() {
+            format!("Term::Ty({:?})", ty)
+        } else if let Some(ct) = self.ct() {
+            format!("Term::Ct({:?})", ct)
+        } else {
+            unreachable!()
+        };
+        f.write_str(&data)
+    }
+}
+
 impl<'tcx> From<Ty<'tcx>> for Term<'tcx> {
     fn from(ty: Ty<'tcx>) -> Self {
         TermKind::Ty(ty).pack()