Skip to content

Commit 7c4eece

Browse files
committed
rustc: pass ty::print::PrintCx by value.
1 parent ab5d6fb commit 7c4eece

File tree

6 files changed

+498
-304
lines changed

6 files changed

+498
-304
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -459,37 +459,52 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
459459
type Path = Vec<String>;
460460

461461
fn path_crate(
462-
self: &mut PrintCx<'_, '_, '_, Self>,
462+
self: PrintCx<'_, '_, '_, Self>,
463463
cnum: CrateNum,
464464
) -> Result<Self::Path, Self::Error> {
465465
Ok(vec![self.tcx.original_crate_name(cnum).to_string()])
466466
}
467467
fn path_qualified<'tcx>(
468-
self: &mut PrintCx<'_, '_, 'tcx, Self>,
469-
_impl_prefix: Option<Self::Path>,
468+
self: PrintCx<'_, '_, 'tcx, Self>,
470469
_self_ty: Ty<'tcx>,
471470
_trait_ref: Option<ty::TraitRef<'tcx>>,
472471
_ns: Namespace,
473472
) -> Result<Self::Path, Self::Error> {
474473
Err(NonTrivialPath)
475474
}
476-
fn path_append(
477-
self: &mut PrintCx<'_, '_, '_, Self>,
478-
mut path: Self::Path,
475+
476+
fn path_append_impl<'gcx, 'tcx>(
477+
self: PrintCx<'_, 'gcx, 'tcx, Self>,
478+
_print_prefix: impl FnOnce(
479+
PrintCx<'_, 'gcx, 'tcx, Self>,
480+
) -> Result<Self::Path, Self::Error>,
481+
_self_ty: Ty<'tcx>,
482+
_trait_ref: Option<ty::TraitRef<'tcx>>,
483+
) -> Result<Self::Path, Self::Error> {
484+
Err(NonTrivialPath)
485+
}
486+
fn path_append<'gcx, 'tcx>(
487+
self: PrintCx<'_, 'gcx, 'tcx, Self>,
488+
print_prefix: impl FnOnce(
489+
PrintCx<'_, 'gcx, 'tcx, Self>,
490+
) -> Result<Self::Path, Self::Error>,
479491
text: &str,
480492
) -> Result<Self::Path, Self::Error> {
493+
let mut path = print_prefix(self)?;
481494
path.push(text.to_string());
482495
Ok(path)
483496
}
484-
fn path_generic_args<'tcx>(
485-
self: &mut PrintCx<'_, '_, 'tcx, Self>,
486-
path: Self::Path,
497+
fn path_generic_args<'gcx, 'tcx>(
498+
self: PrintCx<'_, 'gcx, 'tcx, Self>,
499+
print_prefix: impl FnOnce(
500+
PrintCx<'_, 'gcx, 'tcx, Self>,
501+
) -> Result<Self::Path, Self::Error>,
487502
_params: &[ty::GenericParamDef],
488503
_substs: SubstsRef<'tcx>,
489504
_ns: Namespace,
490505
_projections: impl Iterator<Item = ty::ExistentialProjection<'tcx>>,
491506
) -> Result<Self::Path, Self::Error> {
492-
Ok(path)
507+
print_prefix(self)
493508
}
494509
}
495510

@@ -498,7 +513,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
498513
// module we could have false positives
499514
if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate {
500515
let abs_path = |def_id| {
501-
PrintCx::with(self.tcx, AbsolutePathPrinter, |mut cx| {
516+
PrintCx::with(self.tcx, AbsolutePathPrinter, |cx| {
502517
cx.print_def_path(def_id, None, Namespace::TypeNS, iter::empty())
503518
})
504519
};

src/librustc/mir/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,7 @@ impl<'tcx> Debug for Rvalue<'tcx> {
23692369
};
23702370

23712371
// When printing regions, add trailing space if necessary.
2372-
ty::print::PrintCx::with_tls_tcx(ty::print::FmtPrinter { fmt }, |cx| {
2372+
ty::print::PrintCx::with_tls_tcx(ty::print::FmtPrinter::new(fmt), |cx| {
23732373
let region = if cx.config.is_verbose || cx.config.identify_regions {
23742374
let mut region = region.to_string();
23752375
if region.len() > 0 {

0 commit comments

Comments
 (0)