about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorEduard-Mihai Burtescu <edy.burt@gmail.com>2018-12-28 07:27:44 +0200
committerEduard-Mihai Burtescu <edy.burt@gmail.com>2019-03-15 13:25:10 +0200
commit36f64f15fc0c530493206342d5e4c80f7643fc1d (patch)
tree48de3d4b5c32c301686fe9c49fa447975b9a67e4 /src
parent66cc029dd78ba5df23998a1966c7f9222e5c9c1c (diff)
rustc: remove `ty::print::FORCE_ABSOLUTE` altogether.
Diffstat (limited to 'src')
-rw-r--r--src/librustc/infer/error_reporting/mod.rs4
-rw-r--r--src/librustc/ty/print.rs39
-rw-r--r--src/librustc_codegen_utils/symbol_names.rs8
3 files changed, 6 insertions, 45 deletions
diff --git a/src/librustc/infer/error_reporting/mod.rs b/src/librustc/infer/error_reporting/mod.rs
index 04f0710436b..c27281911aa 100644
--- a/src/librustc/infer/error_reporting/mod.rs
+++ b/src/librustc/infer/error_reporting/mod.rs
@@ -447,7 +447,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
         use hir::def::Namespace;
         use hir::def_id::CrateNum;
         use ty::print::{PrintCx, Printer};
-        use ty::subst::Substs;
+        use ty::subst::SubstsRef;
 
         struct AbsolutePathPrinter;
 
@@ -481,7 +481,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
                 self: &mut PrintCx<'_, '_, 'tcx, Self>,
                 path: Self::Path,
                 _params: &[ty::GenericParamDef],
-                _substs: &'tcx Substs<'tcx>,
+                _substs: SubstsRef<'tcx>,
                 _ns: Namespace,
                 _projections: impl Iterator<Item = ty::ExistentialProjection<'tcx>>,
             ) -> Self::Path {
diff --git a/src/librustc/ty/print.rs b/src/librustc/ty/print.rs
index dca9ddc4a5b..0fda55423aa 100644
--- a/src/librustc/ty/print.rs
+++ b/src/librustc/ty/print.rs
@@ -16,25 +16,10 @@ use std::iter;
 use std::ops::Deref;
 
 thread_local! {
-    static FORCE_ABSOLUTE: Cell<bool> = Cell::new(false);
     static FORCE_IMPL_FILENAME_LINE: Cell<bool> = Cell::new(false);
     static SHOULD_PREFIX_WITH_CRATE: Cell<bool> = Cell::new(false);
 }
 
-/// Enforces that def_path_str always returns an absolute path and
-/// also enables "type-based" impl paths. This is used when building
-/// symbols that contain types, where we want the crate name to be
-/// part of the symbol.
-pub fn with_forced_absolute_paths<F: FnOnce() -> R, R>(f: F) -> R {
-    FORCE_ABSOLUTE.with(|force| {
-        let old = force.get();
-        force.set(true);
-        let result = f();
-        force.set(old);
-        result
-    })
-}
-
 /// Force us to name impls with just the filename/line number. We
 /// normally try to use types. But at some points, notably while printing
 /// cycle errors, this can result in extra or suboptimal error output,
@@ -223,24 +208,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
     }
 
     /// Returns a string identifying this `DefId`. This string is
-    /// suitable for user output. It is relative to the current crate
-    /// root, unless with_forced_absolute_paths was used.
-    pub fn def_path_str_with_substs_and_ns(
-        self,
-        def_id: DefId,
-        substs: Option<SubstsRef<'tcx>>,
-        ns: Namespace,
-    ) -> String {
-        debug!("def_path_str: def_id={:?}, substs={:?}, ns={:?}", def_id, substs, ns);
-        let mut s = String::new();
-        let _ = PrintCx::new(self, FmtPrinter { fmt: &mut s })
-            .print_def_path(def_id, substs, ns, iter::empty());
-        s
-    }
-
-    /// Returns a string identifying this `DefId`. This string is
-    /// suitable for user output. It is relative to the current crate
-    /// root, unless with_forced_absolute_paths was used.
+    /// suitable for user output.
     pub fn def_path_str(self, def_id: DefId) -> String {
         let ns = self.guess_def_namespace(def_id);
         debug!("def_path_str: def_id={:?}, ns={:?}", def_id, ns);
@@ -722,8 +690,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
         // FIXME(eddyb) avoid querying `tcx.generics_of` and `tcx.def_key`
         // both here and in `default_print_def_path`.
         let generics = substs.map(|_| self.tcx.generics_of(def_id));
-        // HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
-        assert!(!FORCE_ABSOLUTE.with(|force| force.get()));
         if generics.as_ref().and_then(|g| g.parent).is_none() {
             if let Some(path) = self.try_print_visible_def_path(def_id) {
                 let path = if let (Some(generics), Some(substs)) = (generics, substs) {
@@ -763,9 +729,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
     }
 
     fn path_crate(self: &mut PrintCx<'_, '_, '_, Self>, cnum: CrateNum) -> Self::Path {
-        // HACK(eddyb) remove the `FORCE_ABSOLUTE` hack by bypassing `FmtPrinter`
-        assert!(!FORCE_ABSOLUTE.with(|force| force.get()));
-
         if cnum == LOCAL_CRATE {
             if self.tcx.sess.rust_2018() {
                 // We add the `crate::` keyword on Rust 2018, only when desired.
diff --git a/src/librustc_codegen_utils/symbol_names.rs b/src/librustc_codegen_utils/symbol_names.rs
index c4de355aa44..8f31e91fa79 100644
--- a/src/librustc_codegen_utils/symbol_names.rs
+++ b/src/librustc_codegen_utils/symbol_names.rs
@@ -225,11 +225,9 @@ fn get_symbol_hash<'a, 'tcx>(
 }
 
 fn def_symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId) -> ty::SymbolName {
-    ty::print::with_forced_absolute_paths(|| {
-        let mut cx = PrintCx::new(tcx, SymbolPath::new(tcx));
-        let _ = cx.print_def_path(def_id, None, Namespace::ValueNS, iter::empty());
-        cx.printer.into_interned()
-    })
+    let mut cx = PrintCx::new(tcx, SymbolPath::new(tcx));
+    let _ = cx.print_def_path(def_id, None, Namespace::ValueNS, iter::empty());
+    cx.printer.into_interned()
 }
 
 fn symbol_name<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: Instance<'tcx>) -> ty::SymbolName {