Skip to content

Commit 82ee912

Browse files
committed
rustc: don't pass Namespace explicitly, but rather track it in FmtPrinter.
1 parent 9c3ec4b commit 82ee912

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
@@ -445,7 +445,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
445445
terr: &TypeError<'tcx>,
446446
sp: Span,
447447
) {
448-
use hir::def::Namespace;
449448
use hir::def_id::CrateNum;
450449
use ty::print::{PrintCx, Printer};
451450
use ty::subst::Substs;
@@ -485,7 +484,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
485484
self: PrintCx<'_, '_, 'tcx, Self>,
486485
_self_ty: Ty<'tcx>,
487486
_trait_ref: Option<ty::TraitRef<'tcx>>,
488-
_ns: Namespace,
489487
) -> Result<Self::Path, Self::Error> {
490488
Err(NonTrivialPath)
491489
}
@@ -518,7 +516,6 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
518516
) -> Result<Self::Path, Self::Error>,
519517
_params: &[ty::GenericParamDef],
520518
_substs: &'tcx Substs<'tcx>,
521-
_ns: Namespace,
522519
_projections: impl Iterator<Item = ty::ExistentialProjection<'tcx>>,
523520
) -> Result<Self::Path, Self::Error> {
524521
print_prefix(self)
@@ -531,7 +528,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
531528
if !(did1.is_local() || did2.is_local()) && did1.krate != did2.krate {
532529
let abs_path = |def_id| {
533530
PrintCx::with(self.tcx, AbsolutePathPrinter, |cx| {
534-
cx.print_def_path(def_id, None, Namespace::TypeNS, iter::empty())
531+
cx.print_def_path(def_id, None, iter::empty())
535532
})
536533
};
537534

src/librustc/infer/error_reporting/need_type_info.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use hir::def::Namespace;
12
use hir::{self, Local, Pat, Body, HirId};
23
use hir::intravisit::{self, Visitor, NestedVisitorMap};
34
use infer::InferCtxt;
@@ -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: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use hir::def::Namespace;
12
use hir::def_id::DefId;
23
use infer::error_reporting::nice_region_error::NiceRegionError;
34
use infer::lexical_region_resolve::RegionResolutionError;
@@ -245,7 +246,7 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
245246

246247
{
247248
let mut note = String::new();
248-
let mut printer = ty::print::FmtPrinter::new(&mut note);
249+
let mut printer = ty::print::FmtPrinter::new(&mut note, Namespace::TypeNS);
249250
printer.region_highlight_mode.maybe_highlighting_region(sub_placeholder, has_sub);
250251
printer.region_highlight_mode.maybe_highlighting_region(sup_placeholder, has_sup);
251252

@@ -279,7 +280,7 @@ impl NiceRegionError<'me, 'gcx, 'tcx> {
279280

280281
{
281282
let mut note = String::new();
282-
let mut printer = ty::print::FmtPrinter::new(&mut note);
283+
let mut printer = ty::print::FmtPrinter::new(&mut note, Namespace::TypeNS);
283284
printer.region_highlight_mode.maybe_highlighting_region(vid, has_vid);
284285

285286
let _ = ty::print::PrintCx::with(self.tcx, printer, |mut cx| {

src/librustc/mir/mod.rs

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

0 commit comments

Comments
 (0)