mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-30 02:33:55 +00:00
Rollup merge of #110660 - compiler-errors:placeholders-pretty, r=wesleywiser,BoxyUwU
Print ty placeholders pretty Makes anon placeholders print like `!0` instead of `Placeholder { ... }`. ``` rustc_trait_selection::solve::compute_well_formed_goal goal=Goal{ predicate: !0, param_env: ParamEnv{ caller_bounds: [ Binder(TraitPredicate(<!0 as std::marker::Copy>, polarity: Positive), []), Binder(TraitPredicate(<!0 as std::clone::Clone>, polarity: Positive), []), Binder(TraitPredicate(<!0 as std::marker::Sized>, polarity: Positive), []), ], reveal: UserFacing, constness: NotConst, } } ``` cc `@BoxyUwU` who might care about this formatting decision
This commit is contained in:
commit
16e2096f0f
@ -738,7 +738,9 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
ty::Placeholder(placeholder) => match placeholder.bound.kind {
|
ty::Placeholder(placeholder) => match placeholder.bound.kind {
|
||||||
ty::BoundTyKind::Anon => p!(write("Placeholder({:?})", placeholder)),
|
ty::BoundTyKind::Anon => {
|
||||||
|
self.pretty_print_placeholder_var(placeholder.universe, placeholder.bound.var)?
|
||||||
|
}
|
||||||
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
|
ty::BoundTyKind::Param(_, name) => p!(write("{}", name)),
|
||||||
},
|
},
|
||||||
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
|
ty::Alias(ty::Opaque, ty::AliasTy { def_id, substs, .. }) => {
|
||||||
@ -1172,6 +1174,18 @@ pub trait PrettyPrinter<'tcx>:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn pretty_print_placeholder_var(
|
||||||
|
&mut self,
|
||||||
|
ui: ty::UniverseIndex,
|
||||||
|
var: ty::BoundVar,
|
||||||
|
) -> Result<(), Self::Error> {
|
||||||
|
if ui == ty::UniverseIndex::ROOT {
|
||||||
|
write!(self, "!{}", var.index())
|
||||||
|
} else {
|
||||||
|
write!(self, "!{}_{}", ui.index(), var.index())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn ty_infer_name(&self, _: ty::TyVid) -> Option<Symbol> {
|
fn ty_infer_name(&self, _: ty::TyVid) -> Option<Symbol> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
@ -203,6 +203,10 @@ pub enum TyKind<I: Interner> {
|
|||||||
/// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
|
/// `for<'a, T> &'a (): Trait<T>` and then convert the introduced bound variables
|
||||||
/// back to inference variables in a new inference context when inside of the query.
|
/// back to inference variables in a new inference context when inside of the query.
|
||||||
///
|
///
|
||||||
|
/// It is conventional to render anonymous bound types like `^N` or `^D_N`,
|
||||||
|
/// where `N` is the bound variable's anonymous index into the binder, and
|
||||||
|
/// `D` is the debruijn index, or totally omitted if the debruijn index is zero.
|
||||||
|
///
|
||||||
/// See the `rustc-dev-guide` for more details about
|
/// See the `rustc-dev-guide` for more details about
|
||||||
/// [higher-ranked trait bounds][1] and [canonical queries][2].
|
/// [higher-ranked trait bounds][1] and [canonical queries][2].
|
||||||
///
|
///
|
||||||
@ -212,6 +216,12 @@ pub enum TyKind<I: Interner> {
|
|||||||
|
|
||||||
/// A placeholder type, used during higher ranked subtyping to instantiate
|
/// A placeholder type, used during higher ranked subtyping to instantiate
|
||||||
/// bound variables.
|
/// bound variables.
|
||||||
|
///
|
||||||
|
/// It is conventional to render anonymous placeholer types like `!N` or `!U_N`,
|
||||||
|
/// where `N` is the placeholder variable's anonymous index (which corresponds
|
||||||
|
/// to the bound variable's index from the binder from which it was instantiated),
|
||||||
|
/// and `U` is the universe index in which it is instantiated, or totally omitted
|
||||||
|
/// if the universe index is zero.
|
||||||
Placeholder(I::PlaceholderType),
|
Placeholder(I::PlaceholderType),
|
||||||
|
|
||||||
/// A type variable used during type checking.
|
/// A type variable used during type checking.
|
||||||
|
Loading…
Reference in New Issue
Block a user