@@ -561,19 +561,33 @@ impl fmt::Display for clean::Type {
561
561
}
562
562
}
563
563
564
+ fn fmt_impl ( i : & clean:: Impl , f : & mut fmt:: Formatter , link_trait : bool ) -> fmt:: Result {
565
+ write ! ( f, "impl{} " , i. generics) ?;
566
+ if let Some ( ref ty) = i. trait_ {
567
+ write ! ( f, "{}" ,
568
+ if i. polarity == Some ( clean:: ImplPolarity :: Negative ) { "!" } else { "" } ) ?;
569
+ if link_trait {
570
+ write ! ( f, "{}" , * ty) ?;
571
+ } else {
572
+ write ! ( f, "{}" , ty. trait_name( ) . unwrap( ) ) ?;
573
+ }
574
+ write ! ( f, " for " ) ?;
575
+ }
576
+ write ! ( f, "{}{}" , i. for_, WhereClause ( & i. generics) ) ?;
577
+ Ok ( ( ) )
578
+ }
579
+
564
580
impl fmt:: Display for clean:: Impl {
565
581
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
566
- write ! ( f, "impl{} " , self . generics) ?;
567
- if let Some ( ref ty) = self . trait_ {
568
- write ! ( f, "{}{} for " ,
569
- if self . polarity == Some ( clean:: ImplPolarity :: Negative ) { "!" } else { "" } ,
570
- * ty) ?;
571
- }
572
- write ! ( f, "{}{}" , self . for_, WhereClause ( & self . generics) ) ?;
573
- Ok ( ( ) )
582
+ fmt_impl ( self , f, true )
574
583
}
575
584
}
576
585
586
+ // The difference from above is that trait is not hyperlinked.
587
+ pub fn fmt_impl_for_trait_page ( i : & clean:: Impl , f : & mut fmt:: Formatter ) -> fmt:: Result {
588
+ fmt_impl ( i, f, false )
589
+ }
590
+
577
591
impl fmt:: Display for clean:: Arguments {
578
592
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
579
593
for ( i, input) in self . values . iter ( ) . enumerate ( ) {
@@ -667,7 +681,7 @@ impl fmt::Display for clean::Import {
667
681
fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
668
682
match * self {
669
683
clean:: SimpleImport ( ref name, ref src) => {
670
- if * name == src. path . segments . last ( ) . unwrap ( ) . name {
684
+ if * name == src. path . last_name ( ) {
671
685
write ! ( f, "use {};" , * src)
672
686
} else {
673
687
write ! ( f, "use {} as {};" , * src, * name)
0 commit comments