Skip to content

Commit 36f64f1

Browse files
committed
rustc: remove ty::print::FORCE_ABSOLUTE altogether.
1 parent 66cc029 commit 36f64f1

File tree

3 files changed

+6
-45
lines changed

3 files changed

+6
-45
lines changed

src/librustc/infer/error_reporting/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
447447
use hir::def::Namespace;
448448
use hir::def_id::CrateNum;
449449
use ty::print::{PrintCx, Printer};
450-
use ty::subst::Substs;
450+
use ty::subst::SubstsRef;
451451

452452
struct AbsolutePathPrinter;
453453

@@ -481,7 +481,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
481481
self: &mut PrintCx<'_, '_, 'tcx, Self>,
482482
path: Self::Path,
483483
_params: &[ty::GenericParamDef],
484-
_substs: &'tcx Substs<'tcx>,
484+
_substs: SubstsRef<'tcx>,
485485
_ns: Namespace,
486486
_projections: impl Iterator<Item = ty::ExistentialProjection<'tcx>>,
487487
) -> Self::Path {

src/librustc/ty/print.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,10 @@ use std::iter;
1616
use std::ops::Deref;
1717

1818
thread_local! {
19-
static FORCE_ABSOLUTE: Cell<bool> = Cell::new(false);
2019
static FORCE_IMPL_FILENAME_LINE: Cell<bool> = Cell::new(false);
2120
static SHOULD_PREFIX_WITH_CRATE: Cell<bool> = Cell::new(false);
2221
}
2322

24-
/// Enforces that def_path_str always returns an absolute path and
25-
/// also enables "type-based" impl paths. This is used when building
26-
/// symbols that contain types, where we want the crate name to be
27-
/// part of the symbol.
28-
pub fn with_forced_absolute_paths<F: FnOnce() -> R, R>(f: F) -> R {
29-
FORCE_ABSOLUTE.with(|force| {
30-
let old = force.get();
31-
force.set(true);
32-
let result = f();
33-
force.set(old);
34-
result
35-
})
36-
}
37-
3823
/// Force us to name impls with just the filename/line number. We
3924
/// normally try to use types. But at some points, notably while printing
4025
/// cycle errors, this can result in extra or suboptimal error output,
@@ -223,24 +208,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
223208
}
224209

225210
/// Returns a string identifying this `DefId`. This string is
226-
/// suitable for user output. It is relative to the current crate
227-
/// root, unless with_forced_absolute_paths was used.
228-
pub fn def_path_str_with_substs_and_ns(
229-
self,
230-
def_id: DefId,
231-
substs: Option<SubstsRef<'tcx>>,
232-
ns: Namespace,
233-
) -> String {
234-
debug!("def_path_str: def_id={:?}, substs={:?}, ns={:?}", def_id, substs, ns);
235-
let mut s = String::new();
236-
let _ = PrintCx::new(self, FmtPrinter { fmt: &mut s })
237-
.print_def_path(def_id, substs, ns, iter::empty());
238-
s
239-
}
240-
241-
/// Returns a string identifying this `DefId`. This string is
242-
/// suitable for user output. It is relative to the current crate
243-
/// root, unless with_forced_absolute_paths was used.
211+
/// suitable for user output.
244212
pub fn def_path_str(self, def_id: DefId) -> String {
245213
let ns = self.guess_def_namespace(def_id);
246214
debug!("def_path_str: def_id={:?}, ns={:?}", def_id, ns);
@@ -722,8 +690,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
722690
// FIXME(eddyb) avoid querying `tcx.generics_of` and `tcx.def_key`
723691
// both here and in `default_print_def_path`.
724692
let generics = substs.map(|_| self.tcx.generics_of(def_id));
725-
// HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
726-
assert!(!FORCE_ABSOLUTE.with(|force| force.get()));
727693
if generics.as_ref().and_then(|g| g.parent).is_none() {
728694
if let Some(path) = self.try_print_visible_def_path(def_id) {
729695
let path = if let (Some(generics), Some(substs)) = (generics, substs) {
@@ -763,9 +729,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
763729
}
764730

765731
fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path {
766-
// HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
767-
assert!(!FORCE_ABSOLUTE.with(|force| force.get()));
768-
769732
if cnum == LOCAL_CRATE {
770733
if self.tcx.sess.rust_2018() {
771734
// We add the `crate::` keyword on Rust 2018, only when desired.

src/librustc_codegen_utils/symbol_names.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,9 @@ fn get_symbol_hash<'a, 'tcx>(
225225
}
226226

227227
fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName {
228-
ty::print::with_forced_absolute_paths(|| {
229-
let mut cx = PrintCx::new(tcx, SymbolPath::new(tcx));
230-
let _ = cx.print_def_path(def_id, None, Namespace::ValueNS, iter::empty());
231-
cx.printer.into_interned()
232-
})
228+
let mut cx = PrintCx::new(tcx, SymbolPath::new(tcx));
229+
let _ = cx.print_def_path(def_id, None, Namespace::ValueNS, iter::empty());
230+
cx.printer.into_interned()
233231
}
234232

235233
fn symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) -> ty::SymbolName {

0 commit comments

Comments
 (0)