提交 fb53bb9e 编写于 作者: E Eduard-Mihai Burtescu

rustc: move Debug impls from ppaux to ty::structural_impls.

上级 9c424850
...@@ -3,17 +3,287 @@ ...@@ -3,17 +3,287 @@
//! hand, though we've recently added some macros (e.g., //! hand, though we've recently added some macros (e.g.,
//! `BraceStructLiftImpl!`) to help with the tedium. //! `BraceStructLiftImpl!`) to help with the tedium.
use crate::hir::def::Namespace;
use crate::mir::ProjectionKind; use crate::mir::ProjectionKind;
use crate::mir::interpret::ConstValue; use crate::mir::interpret::ConstValue;
use crate::ty::{self, Lift, Ty, TyCtxt, ConstVid, InferConst}; use crate::ty::{self, Lift, Ty, TyCtxt, ConstVid, InferConst};
use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor}; use crate::ty::fold::{TypeFoldable, TypeFolder, TypeVisitor};
use crate::ty::print::{FmtPrinter, PrintCx, Printer};
use rustc_data_structures::indexed_vec::{IndexVec, Idx}; use rustc_data_structures::indexed_vec::{IndexVec, Idx};
use smallvec::SmallVec; use smallvec::SmallVec;
use crate::mir::interpret; use crate::mir::interpret;
use std::fmt;
use std::iter;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::rc::Rc; use std::rc::Rc;
impl fmt::Debug for ty::GenericParamDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let type_name = match self.kind {
ty::GenericParamDefKind::Lifetime => "Lifetime",
ty::GenericParamDefKind::Type {..} => "Type",
ty::GenericParamDefKind::Const => "Const",
};
write!(f, "{}({}, {:?}, {})",
type_name,
self.name,
self.def_id,
self.index)
}
}
impl fmt::Debug for ty::TraitDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::TypeNS), |cx| {
cx.print_def_path(self.def_id, None, iter::empty())?;
Ok(())
})
}
}
impl fmt::Debug for ty::AdtDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::TypeNS), |cx| {
cx.print_def_path(self.did, None, iter::empty())?;
Ok(())
})
}
}
impl fmt::Debug for ty::ClosureUpvar<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ClosureUpvar({:?},{:?})",
self.def,
self.ty)
}
}
impl fmt::Debug for ty::UpvarId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = ty::tls::with(|tcx| {
tcx.hir().name_by_hir_id(self.var_path.hir_id)
});
write!(f, "UpvarId({:?};`{}`;{:?})",
self.var_path.hir_id,
name,
self.closure_expr_id)
}
}
impl fmt::Debug for ty::UpvarBorrow<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "UpvarBorrow({:?}, {:?})",
self.kind, self.region)
}
}
impl fmt::Debug for ty::ExistentialTraitRef<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
impl fmt::Debug for ty::adjustment::Adjustment<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?} -> {}", self.kind, self.target)
}
}
impl fmt::Debug for ty::BoundRegion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
ty::BrFresh(n) => write!(f, "BrFresh({:?})", n),
ty::BrNamed(did, name) => {
write!(f, "BrNamed({:?}:{:?}, {})",
did.krate, did.index, name)
}
ty::BrEnv => write!(f, "BrEnv"),
}
}
}
impl fmt::Debug for ty::RegionKind {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::ReEarlyBound(ref data) => {
write!(f, "ReEarlyBound({}, {})",
data.index,
data.name)
}
ty::ReClosureBound(ref vid) => {
write!(f, "ReClosureBound({:?})", vid)
}
ty::ReLateBound(binder_id, ref bound_region) => {
write!(f, "ReLateBound({:?}, {:?})", binder_id, bound_region)
}
ty::ReFree(ref fr) => fr.fmt(f),
ty::ReScope(id) => write!(f, "ReScope({:?})", id),
ty::ReStatic => write!(f, "ReStatic"),
ty::ReVar(ref vid) => vid.fmt(f),
ty::RePlaceholder(placeholder) => {
write!(f, "RePlaceholder({:?})", placeholder)
}
ty::ReEmpty => write!(f, "ReEmpty"),
ty::ReErased => write!(f, "ReErased"),
}
}
}
impl fmt::Debug for ty::FreeRegion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ReFree({:?}, {:?})", self.scope, self.bound_region)
}
}
impl fmt::Debug for ty::Variance {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match *self {
ty::Covariant => "+",
ty::Contravariant => "-",
ty::Invariant => "o",
ty::Bivariant => "*",
})
}
}
impl fmt::Debug for ty::FnSig<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "({:?}; c_variadic: {})->{:?}",
self.inputs(), self.c_variadic, self.output())
}
}
impl fmt::Debug for ty::TyVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}t", self.index)
}
}
impl<'tcx> fmt::Debug for ty::ConstVid<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}c", self.index)
}
}
impl fmt::Debug for ty::IntVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}i", self.index)
}
}
impl fmt::Debug for ty::FloatVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}f", self.index)
}
}
impl fmt::Debug for ty::RegionVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "'_#{}r", self.index())
}
}
impl fmt::Debug for ty::InferTy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::TyVar(ref v) => v.fmt(f),
ty::IntVar(ref v) => v.fmt(f),
ty::FloatVar(ref v) => v.fmt(f),
ty::FreshTy(v) => write!(f, "FreshTy({:?})", v),
ty::FreshIntTy(v) => write!(f, "FreshIntTy({:?})", v),
ty::FreshFloatTy(v) => write!(f, "FreshFloatTy({:?})", v),
}
}
}
impl fmt::Debug for ty::IntVarValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::IntType(ref v) => v.fmt(f),
ty::UintType(ref v) => v.fmt(f),
}
}
}
impl fmt::Debug for ty::FloatVarValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
}
}
impl fmt::Debug for ty::TraitRef<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
// HACK(eddyb) this is used across the compiler to print
// a `TraitRef` qualified (with the Self type explicit),
// instead of having a different way to make that choice.
write!(f, "<{} as {}>", self.self_ty(), self)
}
}
impl fmt::Debug for Ty<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
impl fmt::Debug for ty::ParamTy {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}/#{}", self.name, self.idx)
}
}
impl fmt::Debug for ty::ParamConst {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}/#{}", self.name, self.index)
}
}
impl fmt::Debug for ty::TraitPredicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "TraitPredicate({:?})", self.trait_ref)
}
}
impl fmt::Debug for ty::ProjectionPredicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ProjectionPredicate({:?}, {:?})", self.projection_ty, self.ty)
}
}
impl fmt::Debug for ty::Predicate<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::Predicate::Trait(ref a) => a.fmt(f),
ty::Predicate::Subtype(ref pair) => pair.fmt(f),
ty::Predicate::RegionOutlives(ref pair) => pair.fmt(f),
ty::Predicate::TypeOutlives(ref pair) => pair.fmt(f),
ty::Predicate::Projection(ref pair) => pair.fmt(f),
ty::Predicate::WellFormed(ty) => write!(f, "WellFormed({:?})", ty),
ty::Predicate::ObjectSafe(trait_def_id) => {
write!(f, "ObjectSafe({:?})", trait_def_id)
}
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
write!(f, "ClosureKind({:?}, {:?}, {:?})",
closure_def_id, closure_substs, kind)
}
ty::Predicate::ConstEvaluatable(def_id, substs) => {
write!(f, "ConstEvaluatable({:?}, {:?})", def_id, substs)
}
}
}
}
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
// Atomic structs // Atomic structs
// //
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
use rustc_macros::HashStable; use rustc_macros::HashStable;
use core::intrinsics; use core::intrinsics;
use std::fmt;
use std::cmp::Ordering; use std::cmp::Ordering;
use std::marker::PhantomData; use std::marker::PhantomData;
use std::mem; use std::mem;
...@@ -69,6 +70,16 @@ fn pack(self) -> Kind<'tcx> { ...@@ -69,6 +70,16 @@ fn pack(self) -> Kind<'tcx> {
} }
} }
impl fmt::Debug for Kind<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self.unpack() {
UnpackedKind::Lifetime(lt) => lt.fmt(f),
UnpackedKind::Type(ty) => ty.fmt(f),
UnpackedKind::Const(ct) => ct.fmt(f),
}
}
}
impl<'tcx> Ord for Kind<'tcx> { impl<'tcx> Ord for Kind<'tcx> {
fn cmp(&self, other: &Kind<'_>) -> Ordering { fn cmp(&self, other: &Kind<'_>) -> Ordering {
self.unpack().cmp(&other.unpack()) self.unpack().cmp(&other.unpack())
......
...@@ -2,16 +2,20 @@ ...@@ -2,16 +2,20 @@
use crate::hir::def::Namespace; use crate::hir::def::Namespace;
use crate::ty::subst::{Kind, UnpackedKind}; use crate::ty::subst::{Kind, UnpackedKind};
use crate::ty::{self, ParamConst, Ty}; use crate::ty::{self, ParamConst, Ty};
use crate::ty::print::{FmtPrinter, PrettyPrinter, PrintCx, Print, Printer}; use crate::ty::print::{FmtPrinter, PrettyPrinter, PrintCx, Print};
use crate::mir::interpret::ConstValue; use crate::mir::interpret::ConstValue;
use std::fmt::{self, Write as _}; use std::fmt;
use std::iter; use std::iter;
use rustc_target::spec::abi::Abi; use rustc_target::spec::abi::Abi;
macro_rules! define_print { macro_rules! define_print {
(@display $target:ty, ($self:ident, $cx:ident) $disp:block) => { ([$($target:ty),+] $vars:tt $def:tt) => {
$(define_print!($target, $vars $def);)+
};
($target:ty, ($self:ident, $cx:ident) { display $disp:block }) => {
impl<P: PrettyPrinter> Print<'tcx, P> for $target { impl<P: PrettyPrinter> Print<'tcx, P> for $target {
type Output = P; type Output = P;
type Error = fmt::Error; type Error = fmt::Error;
...@@ -34,38 +38,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -34,38 +38,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
} }
} }
}; };
(@debug $target:ty, ($self:ident, $cx:ident) $dbg:block) => {
impl fmt::Debug for $target {
fn fmt(&$self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::TypeNS), |$cx| {
#[allow(unused_mut)]
let mut $cx = $cx;
define_scoped_cx!($cx);
let _: () = $dbg;
let _ = $cx;
Ok(())
})
}
}
};
([$($target:ty),+] $vars:tt $def:tt) => {
$(define_print!($target, $vars $def);)+
};
($target:ty, $vars:tt {
display $disp:block
debug $dbg:block
}) => {
define_print!(@display $target, $vars $disp);
define_print!(@debug $target, $vars $dbg);
};
($target:ty, $vars:tt {
display $disp:block
}) => {
define_print!(@display $target, $vars $disp);
};
} }
macro_rules! nest { macro_rules! nest {
...@@ -160,67 +132,6 @@ fn fmt(&$self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -160,67 +132,6 @@ fn fmt(&$self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
} }
} }
impl fmt::Debug for ty::GenericParamDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let type_name = match self.kind {
ty::GenericParamDefKind::Lifetime => "Lifetime",
ty::GenericParamDefKind::Type { .. } => "Type",
ty::GenericParamDefKind::Const => "Const",
};
write!(f, "{}({}, {:?}, {})",
type_name,
self.name,
self.def_id,
self.index)
}
}
impl fmt::Debug for ty::TraitDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::TypeNS), |cx| {
cx.print_def_path(self.def_id, None, iter::empty())?;
Ok(())
})
}
}
impl fmt::Debug for ty::AdtDef {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::TypeNS), |cx| {
cx.print_def_path(self.did, None, iter::empty())?;
Ok(())
})
}
}
impl<'tcx> fmt::Debug for ty::ClosureUpvar<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ClosureUpvar({:?},{:?})",
self.def,
self.ty)
}
}
impl fmt::Debug for ty::UpvarId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
PrintCx::with_tls_tcx(FmtPrinter::new(f, Namespace::ValueNS), |mut cx| {
define_scoped_cx!(cx);
p!(write("UpvarId({:?};`{}`;{:?})",
self.var_path.hir_id,
cx.tcx.hir().name_by_hir_id(self.var_path.hir_id),
self.closure_expr_id));
Ok(())
})
}
}
impl<'tcx> fmt::Debug for ty::UpvarBorrow<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "UpvarBorrow({:?}, {:?})",
self.kind, self.region)
}
}
define_print! { define_print! {
&'tcx ty::List<Ty<'tcx>>, (self, cx) { &'tcx ty::List<Ty<'tcx>>, (self, cx) {
display { display {
...@@ -260,91 +171,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -260,91 +171,11 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
} }
} }
impl fmt::Debug for ty::ExistentialTraitRef<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
impl fmt::Debug for ty::adjustment::Adjustment<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{:?} -> {}", self.kind, self.target)
}
}
impl fmt::Debug for ty::BoundRegion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::BrAnon(n) => write!(f, "BrAnon({:?})", n),
ty::BrFresh(n) => write!(f, "BrFresh({:?})", n),
ty::BrNamed(did, name) => {
write!(f, "BrNamed({:?}:{:?}, {})",
did.krate, did.index, name)
}
ty::BrEnv => write!(f, "BrEnv"),
}
}
}
define_print! { define_print! {
ty::RegionKind, (self, cx) { ty::RegionKind, (self, cx) {
display { display {
return cx.print_region(self); return cx.print_region(self);
} }
debug {
match *self {
ty::ReEarlyBound(ref data) => {
p!(write("ReEarlyBound({}, {})",
data.index,
data.name))
}
ty::ReClosureBound(ref vid) => {
p!(write("ReClosureBound({:?})", vid))
}
ty::ReLateBound(binder_id, ref bound_region) => {
p!(write("ReLateBound({:?}, {:?})", binder_id, bound_region))
}
ty::ReFree(ref fr) => p!(write("{:?}", fr)),
ty::ReScope(id) => {
p!(write("ReScope({:?})", id))
}
ty::ReStatic => p!(write("ReStatic")),
ty::ReVar(ref vid) => {
p!(write("{:?}", vid));
}
ty::RePlaceholder(placeholder) => {
p!(write("RePlaceholder({:?})", placeholder))
}
ty::ReEmpty => p!(write("ReEmpty")),
ty::ReErased => p!(write("ReErased"))
}
}
}
}
impl fmt::Debug for ty::FreeRegion {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "ReFree({:?}, {:?})", self.scope, self.bound_region)
}
}
impl fmt::Debug for ty::Variance {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match *self {
ty::Covariant => "+",
ty::Contravariant => "-",
ty::Invariant => "o",
ty::Bivariant => "*",
})
} }
} }
...@@ -362,40 +193,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -362,40 +193,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
p!(write("fn")); p!(write("fn"));
nest!(|cx| cx.pretty_fn_sig(self.inputs(), self.c_variadic, self.output())); nest!(|cx| cx.pretty_fn_sig(self.inputs(), self.c_variadic, self.output()));
} }
debug {
p!(write("({:?}; c_variadic: {})->{:?}",
self.inputs(), self.c_variadic, self.output()))
}
}
}
impl fmt::Debug for ty::TyVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}t", self.index)
}
}
impl<'tcx> fmt::Debug for ty::ConstVid<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}f", self.index)
}
}
impl fmt::Debug for ty::IntVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}i", self.index)
}
}
impl fmt::Debug for ty::FloatVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "_#{}f", self.index)
}
}
impl fmt::Debug for ty::RegionVid {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "'_#{}r", self.index())
} }
} }
...@@ -415,31 +212,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -415,31 +212,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
ty::FreshFloatTy(v) => p!(write("FreshFloatTy({})", v)) ty::FreshFloatTy(v) => p!(write("FreshFloatTy({})", v))
} }
} }
debug {
match *self {
ty::TyVar(ref v) => p!(write("{:?}", v)),
ty::IntVar(ref v) => p!(write("{:?}", v)),
ty::FloatVar(ref v) => p!(write("{:?}", v)),
ty::FreshTy(v) => p!(write("FreshTy({:?})", v)),
ty::FreshIntTy(v) => p!(write("FreshIntTy({:?})", v)),
ty::FreshFloatTy(v) => p!(write("FreshFloatTy({:?})", v))
}
}
}
}
impl fmt::Debug for ty::IntVarValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
ty::IntType(ref v) => v.fmt(f),
ty::UintType(ref v) => v.fmt(f),
}
}
}
impl fmt::Debug for ty::FloatVarValue {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
self.0.fmt(f)
} }
} }
...@@ -478,12 +250,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -478,12 +250,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
display { display {
nest!(|cx| cx.print_def_path(self.def_id, Some(self.substs), iter::empty())); nest!(|cx| cx.print_def_path(self.def_id, Some(self.substs), iter::empty()));
} }
debug {
// HACK(eddyb) this is used across the compiler to print
// a `TraitRef` qualified (with the Self type explicit),
// instead of having a different way to make that choice.
p!(write("<{} as {}>", self.self_ty(), self))
}
} }
} }
...@@ -495,12 +261,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -495,12 +261,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
} }
} }
impl fmt::Debug for Ty<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
fmt::Display::fmt(self, f)
}
}
define_print! { define_print! {
ConstValue<'tcx>, (self, cx) { ConstValue<'tcx>, (self, cx) {
display { display {
...@@ -538,9 +298,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -538,9 +298,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
display { display {
p!(write("{}", self.name)) p!(write("{}", self.name))
} }
debug {
p!(write("{}/#{}", self.name, self.idx))
}
} }
} }
...@@ -549,9 +306,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -549,9 +306,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
display { display {
p!(write("{}", self.name)) p!(write("{}", self.name))
} }
debug {
p!(write("{}/#{}", self.name, self.index))
}
} }
} }
...@@ -581,10 +335,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -581,10 +335,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
display { display {
p!(print(self.trait_ref.self_ty()), write(": "), print(self.trait_ref)) p!(print(self.trait_ref.self_ty()), write(": "), print(self.trait_ref))
} }
debug {
p!(write("TraitPredicate({:?})",
self.trait_ref))
}
} }
} }
...@@ -593,9 +343,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -593,9 +343,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
display { display {
p!(print(self.projection_ty), write(" == "), print(self.ty)) p!(print(self.projection_ty), write(" == "), print(self.ty))
} }
debug {
p!(write("ProjectionPredicate({:?}, {:?})", self.projection_ty, self.ty))
}
} }
} }
...@@ -646,26 +393,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -646,26 +393,6 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
} }
} }
} }
debug {
match *self {
ty::Predicate::Trait(ref a) => p!(write("{:?}", a)),
ty::Predicate::Subtype(ref pair) => p!(write("{:?}", pair)),
ty::Predicate::RegionOutlives(ref pair) => p!(write("{:?}", pair)),
ty::Predicate::TypeOutlives(ref pair) => p!(write("{:?}", pair)),
ty::Predicate::Projection(ref pair) => p!(write("{:?}", pair)),
ty::Predicate::WellFormed(ty) => p!(write("WellFormed({:?})", ty)),
ty::Predicate::ObjectSafe(trait_def_id) => {
p!(write("ObjectSafe({:?})", trait_def_id))
}
ty::Predicate::ClosureKind(closure_def_id, closure_substs, kind) => {
p!(write("ClosureKind({:?}, {:?}, {:?})",
closure_def_id, closure_substs, kind))
}
ty::Predicate::ConstEvaluatable(def_id, substs) => {
p!(write("ConstEvaluatable({:?}, {:?})", def_id, substs))
}
}
}
} }
} }
...@@ -678,12 +405,5 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { ...@@ -678,12 +405,5 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
UnpackedKind::Const(ct) => p!(print(ct)), UnpackedKind::Const(ct) => p!(print(ct)),
} }
} }
debug {
match self.unpack() {
UnpackedKind::Lifetime(lt) => p!(write("{:?}", lt)),
UnpackedKind::Type(ty) => p!(write("{:?}", ty)),
UnpackedKind::Const(ct) => p!(write("{:?}", ct)),
}
}
} }
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册