Skip to content

Commit 534afff

Browse files
committed
rustc: remove ty::print::FORCE_ABSOLUTE altogether.
1 parent 8bf427b commit 534afff

File tree

2 files changed

+4
-43
lines changed

2 files changed

+4
-43
lines changed

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,
@@ -222,24 +207,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
222207
}
223208

224209
/// Returns a string identifying this def-id. This string is
225-
/// suitable for user output. It is relative to the current crate
226-
/// root, unless with_forced_absolute_paths was used.
227-
pub fn def_path_str_with_substs_and_ns(
228-
self,
229-
def_id: DefId,
230-
substs: Option<&'tcx Substs<'tcx>>,
231-
ns: Namespace,
232-
) -> String {
233-
debug!("def_path_str: def_id={:?}, substs={:?}, ns={:?}", def_id, substs, ns);
234-
let mut s = String::new();
235-
let _ = PrintCx::new(self, FmtPrinter { fmt: &mut s })
236-
.print_def_path(def_id, substs, ns, iter::empty());
237-
s
238-
}
239-
240-
/// Returns a string identifying this def-id. This string is
241-
/// suitable for user output. It is relative to the current crate
242-
/// root, unless with_forced_absolute_paths was used.
210+
/// suitable for user output.
243211
pub fn def_path_str(self, def_id: DefId) -> String {
244212
let ns = self.guess_def_namespace(def_id);
245213
debug!("def_path_str: def_id={:?}, ns={:?}", def_id, ns);
@@ -719,8 +687,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
719687
// FIXME(eddyb) avoid querying `tcx.generics_of` and `tcx.def_key`
720688
// both here and in `default_print_def_path`.
721689
let generics = substs.map(|_| self.tcx.generics_of(def_id));
722-
// HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
723-
assert!(!FORCE_ABSOLUTE.with(|force| force.get()));
724690
if generics.as_ref().and_then(|g| g.parent).is_none() {
725691
if let Some(path) = self.try_print_visible_def_path(def_id) {
726692
let path = if let (Some(generics), Some(substs)) = (generics, substs) {
@@ -760,9 +726,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
760726
}
761727

762728
fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path {
763-
// HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
764-
assert!(!FORCE_ABSOLUTE.with(|force| force.get()));
765-
766729
if cnum == LOCAL_CRATE {
767730
if self.tcx.sess.rust_2018() {
768731
// 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
@@ -223,11 +223,9 @@ fn get_symbol_hash<'a, 'tcx>(
223223
}
224224

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

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

0 commit comments

Comments
 (0)