Rename a bit
This commit is contained in:
parent
83fa2faf23
commit
a05a8c80f3
2 changed files with 10 additions and 20 deletions
|
@ -233,11 +233,7 @@ pub trait PrettyPrinter<'tcx>: Printer<'tcx> + fmt::Write {
|
||||||
self.print_def_path(def_id, args)
|
self.print_def_path(def_id, args)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_binder<T>(
|
fn print_in_binder<T>(&mut self, value: &ty::Binder<'tcx, T>) -> Result<(), PrintError>
|
||||||
&mut self,
|
|
||||||
value: &ty::Binder<'tcx, T>,
|
|
||||||
_mode: WrapBinderMode,
|
|
||||||
) -> Result<(), PrintError>
|
|
||||||
where
|
where
|
||||||
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
|
@ -2391,15 +2387,11 @@ impl<'tcx> PrettyPrinter<'tcx> for FmtPrinter<'_, 'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_binder<T>(
|
fn print_in_binder<T>(&mut self, value: &ty::Binder<'tcx, T>) -> Result<(), PrintError>
|
||||||
&mut self,
|
|
||||||
value: &ty::Binder<'tcx, T>,
|
|
||||||
mode: WrapBinderMode,
|
|
||||||
) -> Result<(), PrintError>
|
|
||||||
where
|
where
|
||||||
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
self.pretty_in_binder(value, mode)
|
self.pretty_print_in_binder(value)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn wrap_binder<T, C: FnOnce(&T, &mut Self) -> Result<(), PrintError>>(
|
fn wrap_binder<T, C: FnOnce(&T, &mut Self) -> Result<(), PrintError>>(
|
||||||
|
@ -2835,16 +2827,15 @@ impl<'tcx> FmtPrinter<'_, 'tcx> {
|
||||||
Ok((new_value, map))
|
Ok((new_value, map))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pretty_in_binder<T>(
|
pub fn pretty_print_in_binder<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
value: &ty::Binder<'tcx, T>,
|
value: &ty::Binder<'tcx, T>,
|
||||||
mode: WrapBinderMode,
|
|
||||||
) -> Result<(), fmt::Error>
|
) -> Result<(), fmt::Error>
|
||||||
where
|
where
|
||||||
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
T: Print<'tcx, Self> + TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
let old_region_index = self.region_index;
|
let old_region_index = self.region_index;
|
||||||
let (new_value, _) = self.name_all_regions(value, mode)?;
|
let (new_value, _) = self.name_all_regions(value, WrapBinderMode::ForAll)?;
|
||||||
new_value.print(self)?;
|
new_value.print(self)?;
|
||||||
self.region_index = old_region_index;
|
self.region_index = old_region_index;
|
||||||
self.binder_depth -= 1;
|
self.binder_depth -= 1;
|
||||||
|
@ -2920,7 +2911,7 @@ where
|
||||||
T: Print<'tcx, P> + TypeFoldable<TyCtxt<'tcx>>,
|
T: Print<'tcx, P> + TypeFoldable<TyCtxt<'tcx>>,
|
||||||
{
|
{
|
||||||
fn print(&self, cx: &mut P) -> Result<(), PrintError> {
|
fn print(&self, cx: &mut P) -> Result<(), PrintError> {
|
||||||
cx.in_binder(self, WrapBinderMode::ForAll)
|
cx.print_in_binder(self)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ use rustc_hir::def_id::{CrateNum, DefId};
|
||||||
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
use rustc_hir::definitions::{DefPathData, DisambiguatedDefPathData};
|
||||||
use rustc_middle::bug;
|
use rustc_middle::bug;
|
||||||
use rustc_middle::ty::layout::IntegerExt;
|
use rustc_middle::ty::layout::IntegerExt;
|
||||||
use rustc_middle::ty::print::{Print, PrintError, Printer, WrapBinderMode};
|
use rustc_middle::ty::print::{Print, PrintError, Printer};
|
||||||
use rustc_middle::ty::{
|
use rustc_middle::ty::{
|
||||||
self, FloatTy, GenericArg, GenericArgKind, Instance, IntTy, ReifyReason, Ty, TyCtxt,
|
self, FloatTy, GenericArg, GenericArgKind, Instance, IntTy, ReifyReason, Ty, TyCtxt,
|
||||||
TypeVisitable, TypeVisitableExt, UintTy,
|
TypeVisitable, TypeVisitableExt, UintTy,
|
||||||
|
@ -169,10 +169,9 @@ impl<'tcx> SymbolMangler<'tcx> {
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn in_binder<T>(
|
fn wrap_binder<T>(
|
||||||
&mut self,
|
&mut self,
|
||||||
value: &ty::Binder<'tcx, T>,
|
value: &ty::Binder<'tcx, T>,
|
||||||
_mode: WrapBinderMode,
|
|
||||||
print_value: impl FnOnce(&mut Self, &T) -> Result<(), PrintError>,
|
print_value: impl FnOnce(&mut Self, &T) -> Result<(), PrintError>,
|
||||||
) -> Result<(), PrintError>
|
) -> Result<(), PrintError>
|
||||||
where
|
where
|
||||||
|
@ -472,7 +471,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
||||||
ty::FnPtr(sig_tys, hdr) => {
|
ty::FnPtr(sig_tys, hdr) => {
|
||||||
let sig = sig_tys.with(hdr);
|
let sig = sig_tys.with(hdr);
|
||||||
self.push("F");
|
self.push("F");
|
||||||
self.in_binder(&sig, WrapBinderMode::ForAll, |cx, sig| {
|
self.wrap_binder(&sig, |cx, sig| {
|
||||||
if sig.safety.is_unsafe() {
|
if sig.safety.is_unsafe() {
|
||||||
cx.push("U");
|
cx.push("U");
|
||||||
}
|
}
|
||||||
|
@ -555,7 +554,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
|
||||||
// [<Trait> [{<Projection>}]] [{<Auto>}]
|
// [<Trait> [{<Projection>}]] [{<Auto>}]
|
||||||
// Since any predicates after the first one shouldn't change the binders,
|
// Since any predicates after the first one shouldn't change the binders,
|
||||||
// just put them all in the binders of the first.
|
// just put them all in the binders of the first.
|
||||||
self.in_binder(&predicates[0], WrapBinderMode::ForAll, |cx, _| {
|
self.wrap_binder(&predicates[0], |cx, _| {
|
||||||
for predicate in predicates.iter() {
|
for predicate in predicates.iter() {
|
||||||
// It would be nice to be able to validate bound vars here, but
|
// It would be nice to be able to validate bound vars here, but
|
||||||
// projections can actually include bound vars from super traits
|
// projections can actually include bound vars from super traits
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue