@@ -814,19 +814,22 @@ fn resolved_path(
814
814
if w. alternate ( ) {
815
815
write ! ( w, "{}{:#}" , last. name, last. args. print( cx) ) ?;
816
816
} 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
+ }
824
829
} else {
825
- last. name . to_string ( )
830
+ write ! ( f , "{}" , anchor ( did , last. name, cx ) )
826
831
}
827
- } else {
828
- anchor ( did, last. name , cx) . to_string ( )
829
- } ;
832
+ } ) ;
830
833
write ! ( w, "{path}{args}" , args = last. args. print( cx) ) ?;
831
834
}
832
835
Ok ( ( ) )
@@ -854,16 +857,20 @@ fn primitive_link_fragment(
854
857
match m. primitive_locations . get ( & prim) {
855
858
Some ( & def_id) if def_id. is_local ( ) => {
856
859
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
+ } ) ;
863
871
write ! (
864
872
f,
865
- "<a class=\" primitive\" href=\" {}primitive.{}.html{fragment}\" >" ,
866
- path,
873
+ "<a class=\" primitive\" href=\" {path}primitive.{}.html{fragment}\" >" ,
867
874
prim. as_sym( )
868
875
) ?;
869
876
needs_termination = true ;
0 commit comments