@@ -709,19 +709,22 @@ fn resolved_path(
709709 if w. alternate ( ) {
710710 write ! ( w, "{}{:#}" , last. name, last. args. print( cx) ) ?;
711711 } else {
712- let path = if use_absolute {
713- if let Ok ( ( _, _, fqp) ) = href ( did, cx) {
714- format ! (
715- "{path}::{anchor}" ,
716- path = join_with_double_colon( & fqp[ ..fqp. len( ) - 1 ] ) ,
717- anchor = anchor( did, * fqp. last( ) . unwrap( ) , cx)
718- )
712+ let path = fmt:: from_fn ( |f| {
713+ if use_absolute {
714+ if let Ok ( ( _, _, fqp) ) = href ( did, cx) {
715+ write ! (
716+ f,
717+ "{path}::{anchor}" ,
718+ path = join_with_double_colon( & fqp[ ..fqp. len( ) - 1 ] ) ,
719+ anchor = anchor( did, * fqp. last( ) . unwrap( ) , cx)
720+ )
721+ } else {
722+ write ! ( f, "{}" , last. name)
723+ }
719724 } else {
720- last. name . to_string ( )
725+ write ! ( f , "{}" , anchor ( did , last. name, cx ) )
721726 }
722- } else {
723- anchor ( did, last. name , cx) . to_string ( )
724- } ;
727+ } ) ;
725728 write ! ( w, "{path}{args}" , args = last. args. print( cx) ) ?;
726729 }
727730 Ok ( ( ) )
@@ -749,16 +752,20 @@ fn primitive_link_fragment(
749752 match m. primitive_locations . get ( & prim) {
750753 Some ( & def_id) if def_id. is_local ( ) => {
751754 let len = cx. current . len ( ) ;
752- let path = if len == 0 {
753- let cname_sym = ExternalCrate { crate_num : def_id. krate } . name ( cx. tcx ( ) ) ;
754- format ! ( "{cname_sym}/" )
755- } else {
756- "../" . repeat ( len - 1 )
757- } ;
755+ let path = fmt:: from_fn ( |f| {
756+ if len == 0 {
757+ let cname_sym = ExternalCrate { crate_num : def_id. krate } . name ( cx. tcx ( ) ) ;
758+ write ! ( f, "{cname_sym}/" ) ?;
759+ } else {
760+ for _ in 0 ..( len - 1 ) {
761+ f. write_str ( "../" ) ?;
762+ }
763+ }
764+ Ok ( ( ) )
765+ } ) ;
758766 write ! (
759767 f,
760- "<a class=\" primitive\" href=\" {}primitive.{}.html{fragment}\" >" ,
761- path,
768+ "<a class=\" primitive\" href=\" {path}primitive.{}.html{fragment}\" >" ,
762769 prim. as_sym( )
763770 ) ?;
764771 needs_termination = true ;
0 commit comments