@@ -561,19 +561,33 @@ impl fmt::Display for clean::Type {
561561 }
562562}
563563
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+
564580impl fmt:: Display for clean:: Impl {
565581 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 )
574583 }
575584}
576585
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+
577591impl fmt:: Display for clean:: Arguments {
578592 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
579593 for ( i, input) in self . values . iter ( ) . enumerate ( ) {
@@ -667,7 +681,7 @@ impl fmt::Display for clean::Import {
667681 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
668682 match * self {
669683 clean:: SimpleImport ( ref name, ref src) => {
670- if * name == src. path . segments . last ( ) . unwrap ( ) . name {
684+ if * name == src. path . last_name ( ) {
671685 write ! ( f, "use {};" , * src)
672686 } else {
673687 write ! ( f, "use {} as {};" , * src, * name)
0 commit comments