Skip to content

Commit 5211e37

Browse files
committed
rustc: don't pass Namespace explicitly, but rather track it in FmtPrinter.
1 parent ab26b26 commit 5211e37

File tree

9 files changed

+102
-156
lines changed

9 files changed

+102
-156
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
444444
terr: &TypeError<'tcx>,
445445
sp: Span,
446446
) {
447-
use hir::def::Namespace;
448447
use hir::def_id::CrateNum;
449448
use ty::print::{PrintCx, Printer};
450449
use ty::subst::SubstsRef;
@@ -484,7 +483,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
484483
self: PrintCx<'_, '_, 'tcx, Self>,
485484
_self_ty: Ty<'tcx>,
486485
_trait_ref: Option<ty::TraitRef<'tcx>>,
487-
_ns: Namespace,
488486
) -> Result<Self::Path, Self::Error> {
489487
Err(NonTrivialPath)
490488
}
@@ -517,7 +515,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
517515
) -> Result<Self::Path, Self::Error>,
518516
_params: &[ty::GenericParamDef],
519517
_substs: SubstsRef<'tcx>,
520-
_ns: Namespace,
521518
_projections: impl Iterator<Item = ty::ExistentialProjection<'tcx>>,
522519
) -> Result<Self::Path, Self::Error> {
523520
print_prefix(self)
@@ -530,7 +527,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
530527
if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate {
531528
let abs_path = |def_id| {
532529
PrintCx::with(self.tcx, AbsolutePathPrinter, |cx| {
533-
cx.print_def_path(def_id, None, Namespace::TypeNS, iter::empty())
530+
cx.print_def_path(def_id, None, iter::empty())
534531
})
535532
};
536533

src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1+
use crate::hir::def::Namespace;
12
use crate::hir::{self, Local, Pat, Body, HirId};
23
use crate::hir::intravisit::{self, Visitor, NestedVisitorMap};
34
use crate::infer::InferCtxt;
45
use crate::infer::type_variable::TypeVariableOrigin;
56
use crate::ty::{self, Ty, Infer, TyVar};
6-
use ty::print::Print;
7+
use crate::ty::print::Print;
78
use syntax::source_map::CompilerDesugaringKind;
89
use syntax_pos::Span;
910
use errors::DiagnosticBuilder;
@@ -79,7 +80,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
7980
}
8081

8182
let mut s = String::new();
82-
let mut printer = ty::print::FmtPrinter::new(&mut s);
83+
let mut printer = ty::print::FmtPrinter::new(&mut s, Namespace::TypeNS);
8384
if let Some(highlight) = highlight {
8485
printer.region_highlight_mode = highlight;
8586
}

src/librustc/infer/error_reporting/nice_region_error/placeholder_error.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use errors::DiagnosticBuilder;
2+
use crate::hir::def::Namespace;
23
use crate::hir::def_id::DefId;
34
use crate::infer::error_reporting::nice_region_error::NiceRegionError;
45
use crate::infer::lexical_region_resolve::RegionResolutionError;
@@ -343,7 +344,7 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
343344
>,
344345
{
345346
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
346-
let mut printer = ty::print::FmtPrinter::new(f);
347+
let mut printer = ty::print::FmtPrinter::new(f, Namespace::TypeNS);
347348
printer.region_highlight_mode = self.highlight;
348349

349350
ty::print::PrintCx::with(self.tcx, printer, |cx| {

src/librustc/mir/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2369,7 +2369,8 @@ 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::new(fmt), |cx| {
2372+
let ns = Namespace::ValueNS;
2373+
ty::print::PrintCx::with_tls_tcx(ty::print::FmtPrinter::new(fmt, ns), |cx| {
23732374
let region = if cx.config.is_verbose || cx.config.identify_regions {
23742375
let mut region = region.to_string();
23752376
if region.len() > 0 {

0 commit comments

Comments
 (0)