mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 08:44:35 +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::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::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> {
|
||||
None
|
||||
}
|
||||
|
@ -203,6 +203,10 @@ pub enum TyKind<I: Interner> {
|
||||
/// `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.
|
||||
///
|
||||
/// 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
|
||||
/// [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
|
||||
/// 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),
|
||||
|
||||
/// A type variable used during type checking.
|
||||
|
Loading…
Reference in New Issue
Block a user