@@ -16,25 +16,10 @@ use std::iter;
16
16
use std:: ops:: Deref ;
17
17
18
18
thread_local ! {
19
- static FORCE_ABSOLUTE : Cell <bool > = Cell :: new( false ) ;
20
19
static FORCE_IMPL_FILENAME_LINE : Cell <bool > = Cell :: new( false ) ;
21
20
static SHOULD_PREFIX_WITH_CRATE : Cell <bool > = Cell :: new( false ) ;
22
21
}
23
22
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
-
38
23
/// Force us to name impls with just the filename/line number. We
39
24
/// normally try to use types. But at some points, notably while printing
40
25
/// cycle errors, this can result in extra or suboptimal error output,
@@ -223,24 +208,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
223
208
}
224
209
225
210
/// 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.
244
212
pub fn def_path_str ( self , def_id : DefId ) -> String {
245
213
let ns = self . guess_def_namespace ( def_id) ;
246
214
debug ! ( "def_path_str: def_id={:?}, ns={:?}" , def_id, ns) ;
@@ -722,8 +690,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
722
690
// FIXME(eddyb) avoid querying `tcx.generics_of` and `tcx.def_key`
723
691
// both here and in `default_print_def_path`.
724
692
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( ) ) ) ;
727
693
if generics. as_ref ( ) . and_then ( |g| g. parent ) . is_none ( ) {
728
694
if let Some ( path) = self . try_print_visible_def_path ( def_id) {
729
695
let path = if let ( Some ( generics) , Some ( substs) ) = ( generics, substs) {
@@ -763,9 +729,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
763
729
}
764
730
765
731
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
-
769
732
if cnum == LOCAL_CRATE {
770
733
if self . tcx . sess . rust_2018 ( ) {
771
734
// We add the `crate::` keyword on Rust 2018, only when desired.
0 commit comments