Skip to content

Commit 3cbe070

Browse files
committed
rustc: pass ty::print::PrintCx by value.
1 parent d993429 commit 3cbe070

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
@@ -460,37 +460,52 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
460460
type Path = Vec<String>;
461461

462462
fn path_crate(
463-
self: &mut PrintCx<'_, '_, '_, Self>,
463+
self: PrintCx<'_, '_, '_, Self>,
464464
cnum: CrateNum,
465465
) -> Result<Self::Path, Self::Error> {
466466
Ok(vec![self.tcx.original_crate_name(cnum).to_string()])
467467
}
468468
fn path_qualified<'tcx>(
469-
self: &mut PrintCx<'_, '_, 'tcx, Self>,
470-
_impl_prefix: Option<Self::Path>,
469+
self: PrintCx<'_, '_, 'tcx, Self>,
471470
_self_ty: Ty<'tcx>,
472471
_trait_ref: Option<ty::TraitRef<'tcx>>,
473472
_ns: Namespace,
474473
) -> Result<Self::Path, Self::Error> {
475474
Err(NonTrivialPath)
476475
}
477-
fn path_append(
478-
self: &mut PrintCx<'_, '_, '_, Self>,
479-
mut path: Self::Path,
476+
477+
fn path_append_impl<'gcx, 'tcx>(
478+
self: PrintCx<'_, 'gcx, 'tcx, Self>,
479+
_print_prefix: impl FnOnce(
480+
PrintCx<'_, 'gcx, 'tcx, Self>,
481+
) -> Result<Self::Path, Self::Error>,
482+
_self_ty: Ty<'tcx>,
483+
_trait_ref: Option<ty::TraitRef<'tcx>>,
484+
) -> Result<Self::Path, Self::Error> {
485+
Err(NonTrivialPath)
486+
}
487+
fn path_append<'gcx, 'tcx>(
488+
self: PrintCx<'_, 'gcx, 'tcx, Self>,
489+
print_prefix: impl FnOnce(
490+
PrintCx<'_, 'gcx, 'tcx, Self>,
491+
) -> Result<Self::Path, Self::Error>,
480492
text: &str,
481493
) -> Result<Self::Path, Self::Error> {
494+
let mut path = print_prefix(self)?;
482495
path.push(text.to_string());
483496
Ok(path)
484497
}
485-
fn path_generic_args<'tcx>(
486-
self: &mut PrintCx<'_, '_, 'tcx, Self>,
487-
path: Self::Path,
498+
fn path_generic_args<'gcx, 'tcx>(
499+
self: PrintCx<'_, 'gcx, 'tcx, Self>,
500+
print_prefix: impl FnOnce(
501+
PrintCx<'_, 'gcx, 'tcx, Self>,
502+
) -> Result<Self::Path, Self::Error>,
488503
_params: &[ty::GenericParamDef],
489504
_substs: &'tcx Substs<'tcx>,
490505
_ns: Namespace,
491506
_projections: impl Iterator<Item = ty::ExistentialProjection<'tcx>>,
492507
) -> Result<Self::Path, Self::Error> {
493-
Ok(path)
508+
print_prefix(self)
494509
}
495510
}
496511

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

src/librustc/mir/mod.rs

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

23432343
// When printing regions, add trailing space if necessary.
2344-
ty::print::PrintCx::with_tls_tcx(ty::print::FmtPrinter { fmt }, |cx| {
2344+
ty::print::PrintCx::with_tls_tcx(ty::print::FmtPrinter::new(fmt), |cx| {
23452345
let region = if cx.config.is_verbose || cx.config.identify_regions {
23462346
let mut region = region.to_string();
23472347
if region.len() > 0 {

0 commit comments

Comments
 (0)