use core::intrinsics;
use std::cmp::Ordering;
-use std::fmt;
use std::marker::PhantomData;
use std::mem;
use std::num::NonZeroUsize;
}
}
-impl<'tcx> fmt::Debug for Kind<'tcx> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self.unpack() {
- UnpackedKind::Lifetime(lt) => write!(f, "{:?}", lt),
- UnpackedKind::Type(ty) => write!(f, "{:?}", ty),
UnpackedKind::Const(ct) => write!(f, "{:?}", ct),
- }
- }
-}
-
-impl<'tcx> fmt::Display for Kind<'tcx> {
- fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
- match self.unpack() {
- UnpackedKind::Lifetime(lt) => write!(f, "{}", lt),
- UnpackedKind::Type(ty) => write!(f, "{}", ty),
UnpackedKind::Const(ct) => write!(f, "{}", ct),
- }
- }
-}
-
impl<'a, 'tcx> Lift<'tcx> for Kind<'a> {
type Lifted = Kind<'tcx>;
use crate::hir::def_id::DefId;
use crate::hir::map::definitions::DefPathData;
use crate::middle::region;
-use crate::ty::subst::{self, Subst, SubstsRef};
+use crate::ty::subst::{self, Kind, Subst, SubstsRef, UnpackedKind};
use crate::ty::{BrAnon, BrEnv, BrFresh, BrNamed};
use crate::ty::{Bool, Char, Adt};
use crate::ty::{Error, Str, Array, Slice, Float, FnDef, FnPtr};
}
}
}
+
+define_print! {
+ ('tcx) Kind<'tcx>, (self, f, cx) {
+ display {
+ match self.unpack() {
+ UnpackedKind::Lifetime(lt) => print!(f, cx, print(lt)),
+ UnpackedKind::Type(ty) => print!(f, cx, print(ty)),
+ }
+ }
+ debug {
+ match self.unpack() {
+ UnpackedKind::Lifetime(lt) => print!(f, cx, print(lt)),
+ UnpackedKind::Type(ty) => print!(f, cx, print(ty)),
+ }
+ }
+ }
+}