Fix pretty printing of placeholder types
This commit is contained in:
parent
74570e526e
commit
d79b669b09
8 changed files with 41 additions and 36 deletions
|
|
@ -655,7 +655,7 @@ impl<'tcx> fmt::Display for GenericKind<'tcx> {
|
|||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match *self {
|
||||
GenericKind::Param(ref p) => write!(f, "{p}"),
|
||||
GenericKind::Placeholder(ref p) => write!(f, "{p:?}"),
|
||||
GenericKind::Placeholder(ref p) => write!(f, "{p}"),
|
||||
GenericKind::Alias(ref p) => write!(f, "{p}"),
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -822,13 +822,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
|||
ty::Alias(ty::Projection | ty::Inherent | ty::Free, ref data) => {
|
||||
p!(print(data))
|
||||
}
|
||||
ty::Placeholder(placeholder) => match placeholder.bound.kind {
|
||||
ty::BoundTyKind::Anon => p!(write("{placeholder:?}")),
|
||||
ty::BoundTyKind::Param(def_id) => match self.should_print_verbose() {
|
||||
true => p!(write("{:?}", ty.kind())),
|
||||
false => p!(write("{}", self.tcx().item_name(def_id))),
|
||||
},
|
||||
},
|
||||
ty::Placeholder(placeholder) => p!(print(placeholder)),
|
||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, args, .. }) => {
|
||||
// We use verbose printing in 'NO_QUERIES' mode, to
|
||||
// avoid needing to call `predicates_of`. This should
|
||||
|
|
@ -3373,6 +3367,16 @@ define_print_and_forward_display! {
|
|||
p!(write("{}", self.name))
|
||||
}
|
||||
|
||||
ty::PlaceholderType {
|
||||
match self.bound.kind {
|
||||
ty::BoundTyKind::Anon => p!(write("{self:?}")),
|
||||
ty::BoundTyKind::Param(def_id) => match cx.should_print_verbose() {
|
||||
true => p!(write("{self:?}")),
|
||||
false => p!(write("{}", cx.tcx().item_name(def_id))),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
ty::ParamConst {
|
||||
p!(write("{}", self.name))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -272,7 +272,6 @@ TrivialTypeTraversalImpls! {
|
|||
crate::ty::BoundVar,
|
||||
crate::ty::InferConst,
|
||||
crate::ty::Placeholder<crate::ty::BoundRegion>,
|
||||
crate::ty::Placeholder<crate::ty::BoundTy>,
|
||||
crate::ty::Placeholder<ty::BoundVar>,
|
||||
crate::ty::UserTypeAnnotationIndex,
|
||||
crate::ty::ValTree<'tcx>,
|
||||
|
|
@ -303,6 +302,7 @@ TrivialTypeTraversalAndLiftImpls! {
|
|||
// tidy-alphabetical-start
|
||||
crate::ty::ParamConst,
|
||||
crate::ty::ParamTy,
|
||||
crate::ty::Placeholder<crate::ty::BoundTy>,
|
||||
crate::ty::instance::ReifyReason,
|
||||
rustc_hir::def_id::DefId,
|
||||
// tidy-alphabetical-end
|
||||
|
|
|
|||
|
|
@ -713,14 +713,14 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
}
|
||||
|
||||
let labeled_user_string = match bound_kind {
|
||||
GenericKind::Param(ref p) => format!("the parameter type `{p}`"),
|
||||
GenericKind::Placeholder(ref p) => format!("the placeholder type `{p:?}`"),
|
||||
GenericKind::Alias(ref p) => match p.kind(self.tcx) {
|
||||
GenericKind::Param(_) => format!("the parameter type `{bound_kind}`"),
|
||||
GenericKind::Placeholder(_) => format!("the placeholder type `{bound_kind}`"),
|
||||
GenericKind::Alias(p) => match p.kind(self.tcx) {
|
||||
ty::Projection | ty::Inherent => {
|
||||
format!("the associated type `{p}`")
|
||||
format!("the associated type `{bound_kind}`")
|
||||
}
|
||||
ty::Free => format!("the type alias `{p}`"),
|
||||
ty::Opaque => format!("the opaque type `{p}`"),
|
||||
ty::Free => format!("the type alias `{bound_kind}`"),
|
||||
ty::Opaque => format!("the opaque type `{bound_kind}`"),
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue