@@ -442,7 +442,7 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
442
442
/// Used when rendering a `ResolvedPath` structure. This invokes the `path`
443
443
/// rendering function with the necessary arguments for linking to a local path.
444
444
fn resolved_path ( w : & mut fmt:: Formatter , did : DefId , path : & clean:: Path ,
445
- print_all : bool , use_absolute : bool ) -> fmt:: Result {
445
+ print_all : bool , use_absolute : bool , is_not_debug : bool ) -> fmt:: Result {
446
446
let last = path. segments . last ( ) . unwrap ( ) ;
447
447
let rel_root = match & * path. segments [ 0 ] . name {
448
448
"self" => Some ( "./" . to_string ( ) ) ,
@@ -459,10 +459,14 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
459
459
} else {
460
460
root. push_str ( & seg. name ) ;
461
461
root. push_str ( "/" ) ;
462
- write ! ( w, "<a class=\" mod\"
463
- href=\" {}index.html\" >{}</a>::" ,
464
- root,
465
- seg. name) ?;
462
+ if is_not_debug {
463
+ write ! ( w, "<a class=\" mod\"
464
+ href=\" {}index.html\" >{}</a>::" ,
465
+ root,
466
+ seg. name) ?;
467
+ } else {
468
+ write ! ( w, "{}::" , seg. name) ?;
469
+ }
466
470
}
467
471
}
468
472
}
@@ -474,19 +478,37 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
474
478
}
475
479
}
476
480
if w. alternate ( ) {
477
- write ! ( w, "{:#}{:#}" , HRef :: new( did, & last. name) , last. params) ?;
481
+ if is_not_debug {
482
+ write ! ( w, "{:#}{:#}" , HRef :: new( did, & last. name) , last. params) ?;
483
+ } else {
484
+ write ! ( w, "{:?}{:?}" , HRef :: new( did, & last. name) , last. params) ?;
485
+ }
478
486
} else {
479
- let path = if use_absolute {
480
- match href ( did) {
481
- Some ( ( _, _, fqp) ) => format ! ( "{}::{}" ,
482
- fqp[ ..fqp. len( ) -1 ] . join( "::" ) ,
483
- HRef :: new( did, fqp. last( ) . unwrap( ) ) ) ,
484
- None => format ! ( "{}" , HRef :: new( did, & last. name) ) ,
485
- }
487
+ if is_not_debug {
488
+ let path = if use_absolute {
489
+ match href ( did) {
490
+ Some ( ( _, _, fqp) ) => format ! ( "{}::{}" ,
491
+ fqp[ ..fqp. len( ) -1 ] . join( "::" ) ,
492
+ HRef :: new( did, fqp. last( ) . unwrap( ) ) ) ,
493
+ None => format ! ( "{}" , HRef :: new( did, & last. name) ) ,
494
+ }
495
+ } else {
496
+ format ! ( "{}" , HRef :: new( did, & last. name) )
497
+ } ;
498
+ write ! ( w, "{}{}" , path, last. params) ?;
486
499
} else {
487
- format ! ( "{}" , HRef :: new( did, & last. name) )
488
- } ;
489
- write ! ( w, "{}{}" , path, last. params) ?;
500
+ let path = if use_absolute {
501
+ match href ( did) {
502
+ Some ( ( _, _, fqp) ) => format ! ( "{:?}::{:?}" ,
503
+ fqp[ ..fqp. len( ) -1 ] . join( "::" ) ,
504
+ HRef :: new( did, fqp. last( ) . unwrap( ) ) ) ,
505
+ None => format ! ( "{:?}" , HRef :: new( did, & last. name) ) ,
506
+ }
507
+ } else {
508
+ format ! ( "{:?}" , HRef :: new( did, & last. name) )
509
+ } ;
510
+ write ! ( w, "{}{:?}" , path, last. params) ?;
511
+ }
490
512
}
491
513
Ok ( ( ) )
492
514
}
@@ -570,6 +592,12 @@ impl<'a> fmt::Display for HRef<'a> {
570
592
}
571
593
}
572
594
595
+ impl < ' a > fmt:: Debug for HRef < ' a > {
596
+ fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
597
+ write ! ( f, "{}" , self . text)
598
+ }
599
+ }
600
+
573
601
fn fmt_type ( t : & clean:: Type , f : & mut fmt:: Formatter , use_absolute : bool ,
574
602
is_not_debug : bool ) -> fmt:: Result {
575
603
match * t {
@@ -578,7 +606,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
578
606
}
579
607
clean:: ResolvedPath { did, ref typarams, ref path, is_generic } => {
580
608
// Paths like T::Output and Self::Output should be rendered with all segments
581
- resolved_path ( f, did, path, is_generic, use_absolute) ?;
609
+ resolved_path ( f, did, path, is_generic, use_absolute, is_not_debug ) ?;
582
610
tybounds ( f, typarams)
583
611
}
584
612
clean:: Infer => write ! ( f, "_" ) ,
@@ -767,7 +795,7 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool,
767
795
write ! ( f, "{}::" , self_type) ?;
768
796
}
769
797
let path = clean:: Path :: singleton ( name. clone ( ) ) ;
770
- resolved_path ( f, did, & path, true , use_absolute) ?;
798
+ resolved_path ( f, did, & path, true , use_absolute, is_not_debug ) ?;
771
799
772
800
// FIXME: `typarams` are not rendered, and this seems bad?
773
801
drop ( typarams) ;
@@ -1051,7 +1079,7 @@ impl fmt::Display for clean::Import {
1051
1079
impl fmt:: Display for clean:: ImportSource {
1052
1080
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
1053
1081
match self . did {
1054
- Some ( did) => resolved_path ( f, did, & self . path , true , false ) ,
1082
+ Some ( did) => resolved_path ( f, did, & self . path , true , false , true ) ,
1055
1083
_ => {
1056
1084
for ( i, seg) in self . path . segments . iter ( ) . enumerate ( ) {
1057
1085
if i > 0 {
0 commit comments