@@ -459,22 +459,10 @@ pub fn href(did: DefId) -> Option<(String, ItemType, Vec<String>)> {
459
459
/// rendering function with the necessary arguments for linking to a local path.
460
460
fn resolved_path ( w : & mut fmt:: Formatter , did : DefId , path : & clean:: Path ,
461
461
print_all : bool , use_absolute : bool ) -> fmt:: Result {
462
- let empty = clean:: PathSegment {
463
- name : String :: new ( ) ,
464
- params : clean:: PathParameters :: Parenthesized {
465
- inputs : Vec :: new ( ) ,
466
- output : None ,
467
- }
468
- } ;
469
- let last = path. segments . last ( )
470
- . unwrap_or ( & empty) ;
471
- let rel_root = if path. segments . is_empty ( ) {
472
- None
473
- } else {
474
- match & * path. segments [ 0 ] . name {
475
- "self" => Some ( "./" . to_string ( ) ) ,
476
- _ => None ,
477
- }
462
+ let last = path. segments . last ( ) . unwrap ( ) ;
463
+ let rel_root = match & * path. segments [ 0 ] . name {
464
+ "self" => Some ( "./" . to_string ( ) ) ,
465
+ _ => None ,
478
466
} ;
479
467
480
468
if print_all {
@@ -508,7 +496,7 @@ fn resolved_path(w: &mut fmt::Formatter, did: DefId, path: &clean::Path,
508
496
Some ( ( _, _, fqp) ) => {
509
497
format ! ( "{}::{}" ,
510
498
fqp[ ..fqp. len( ) - 1 ] . join( "::" ) ,
511
- HRef :: new( did, fqp. last( ) . unwrap_or ( & String :: new ( ) ) ) )
499
+ HRef :: new( did, fqp. last( ) . unwrap ( ) ) )
512
500
}
513
501
None => format ! ( "{}" , HRef :: new( did, & last. name) ) ,
514
502
}
@@ -740,10 +728,8 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
740
728
}
741
729
clean:: QPath { ref name, ref self_type, ref trait_ } => {
742
730
let should_show_cast = match * trait_ {
743
- box clean:: ResolvedPath { .. } => {
744
- let path = clean:: Path :: singleton ( name. clone ( ) ) ;
745
- !path. segments . is_empty ( ) && & format ! ( "{:#}" , trait_) != "()" &&
746
- & format ! ( "{:#}" , self_type) != "Self"
731
+ box clean:: ResolvedPath { ref path, .. } => {
732
+ !path. segments . is_empty ( ) && !self_type. is_self_type ( )
747
733
}
748
734
_ => true ,
749
735
} ;
@@ -772,8 +758,18 @@ fn fmt_type(t: &clean::Type, f: &mut fmt::Formatter, use_absolute: bool) -> fmt:
772
758
// everything comes in as a fully resolved QPath (hard to
773
759
// look at).
774
760
box clean:: ResolvedPath { did, ref typarams, .. } => {
775
- let path = clean:: Path :: singleton ( name. clone ( ) ) ;
776
- resolved_path ( f, did, & path, true , use_absolute) ?;
761
+ match href ( did) {
762
+ Some ( ( ref url, _, ref path) ) if !f. alternate ( ) => {
763
+ write ! ( f,
764
+ "<a class=\" type\" href=\" {url}#{shortty}.{name}\" \
765
+ title=\" type {path}::{name}\" >{name}</a>",
766
+ url = url,
767
+ shortty = ItemType :: AssociatedType ,
768
+ name = name,
769
+ path = path. join( "::" ) ) ?;
770
+ }
771
+ _ => write ! ( f, "{}" , name) ?,
772
+ }
777
773
778
774
// FIXME: `typarams` are not rendered, and this seems bad?
779
775
drop ( typarams) ;
0 commit comments