@@ -814,19 +814,22 @@ fn resolved_path(
814814 if w. alternate ( ) {
815815 write ! ( w, "{}{:#}" , last. name, last. args. print( cx) ) ?;
816816 } else {
817- let path = if use_absolute {
818- if let Ok ( ( _, _, fqp) ) = href ( did, cx) {
819- format ! (
820- "{path}::{anchor}" ,
821- path = join_with_double_colon( & fqp[ ..fqp. len( ) - 1 ] ) ,
822- anchor = anchor( did, * fqp. last( ) . unwrap( ) , cx)
823- )
817+ let path = fmt:: from_fn ( |f| {
818+ if use_absolute {
819+ if let Ok ( ( _, _, fqp) ) = href ( did, cx) {
820+ write ! (
821+ f,
822+ "{path}::{anchor}" ,
823+ path = join_with_double_colon( & fqp[ ..fqp. len( ) - 1 ] ) ,
824+ anchor = anchor( did, * fqp. last( ) . unwrap( ) , cx)
825+ )
826+ } else {
827+ write ! ( f, "{}" , last. name)
828+ }
824829 } else {
825- last. name . to_string ( )
830+ write ! ( f , "{}" , anchor ( did , last. name, cx ) )
826831 }
827- } else {
828- anchor ( did, last. name , cx) . to_string ( )
829- } ;
832+ } ) ;
830833 write ! ( w, "{path}{args}" , args = last. args. print( cx) ) ?;
831834 }
832835 Ok ( ( ) )
@@ -854,16 +857,20 @@ fn primitive_link_fragment(
854857 match m. primitive_locations . get ( & prim) {
855858 Some ( & def_id) if def_id. is_local ( ) => {
856859 let len = cx. current . len ( ) ;
857- let path = if len == 0 {
858- let cname_sym = ExternalCrate { crate_num : def_id. krate } . name ( cx. tcx ( ) ) ;
859- format ! ( "{cname_sym}/" )
860- } else {
861- "../" . repeat ( len - 1 )
862- } ;
860+ let path = fmt:: from_fn ( |f| {
861+ if len == 0 {
862+ let cname_sym = ExternalCrate { crate_num : def_id. krate } . name ( cx. tcx ( ) ) ;
863+ write ! ( f, "{cname_sym}/" ) ?;
864+ } else {
865+ for _ in 0 ..( len - 1 ) {
866+ f. write_str ( "../" ) ?;
867+ }
868+ }
869+ Ok ( ( ) )
870+ } ) ;
863871 write ! (
864872 f,
865- "<a class=\" primitive\" href=\" {}primitive.{}.html{fragment}\" >" ,
866- path,
873+ "<a class=\" primitive\" href=\" {path}primitive.{}.html{fragment}\" >" ,
867874 prim. as_sym( )
868875 ) ?;
869876 needs_termination = true ;
0 commit comments