@@ -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,
@@ -222,24 +207,7 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
222
207
}
223
208
224
209
/// 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.
243
211
pub fn def_path_str ( self , def_id : DefId ) -> String {
244
212
let ns = self . guess_def_namespace ( def_id) ;
245
213
debug ! ( "def_path_str: def_id={:?}, ns={:?}" , def_id, ns) ;
@@ -719,8 +687,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
719
687
// FIXME(eddyb) avoid querying `tcx.generics_of` and `tcx.def_key`
720
688
// both here and in `default_print_def_path`.
721
689
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( ) ) ) ;
724
690
if generics. as_ref ( ) . and_then ( |g| g. parent ) . is_none ( ) {
725
691
if let Some ( path) = self . try_print_visible_def_path ( def_id) {
726
692
let path = if let ( Some ( generics) , Some ( substs) ) = ( generics, substs) {
@@ -760,9 +726,6 @@ impl<F: fmt::Write> Printer for FmtPrinter<F> {
760
726
}
761
727
762
728
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
-
766
729
if cnum == LOCAL_CRATE {
767
730
if self . tcx . sess . rust_2018 ( ) {
768
731
// We add the `crate::` keyword on Rust 2018, only when desired.
0 commit comments