@@ -569,7 +569,7 @@ fn generate_macro_def_id_path(
569
569
root_path : Option < & str > ,
570
570
) -> Result < ( String , ItemType , Vec < Symbol > ) , HrefError > {
571
571
let tcx = cx. shared . tcx ;
572
- let crate_name = tcx. crate_name ( def_id. krate ) . to_string ( ) ;
572
+ let crate_name = tcx. crate_name ( def_id. krate ) ;
573
573
let cache = cx. cache ( ) ;
574
574
575
575
let fqp: Vec < Symbol > = tcx
@@ -584,7 +584,7 @@ fn generate_macro_def_id_path(
584
584
}
585
585
} )
586
586
. collect ( ) ;
587
- let mut relative = fqp. iter ( ) . map ( |elem| elem . to_string ( ) ) ;
587
+ let mut relative = fqp. iter ( ) . copied ( ) ;
588
588
let cstore = CStore :: from_tcx ( tcx) ;
589
589
// We need this to prevent a `panic` when this function is used from intra doc links...
590
590
if !cstore. has_crate_data ( def_id. krate ) {
@@ -602,9 +602,9 @@ fn generate_macro_def_id_path(
602
602
} ;
603
603
604
604
let mut path = if is_macro_2 {
605
- once ( crate_name. clone ( ) ) . chain ( relative) . collect ( )
605
+ once ( crate_name) . chain ( relative) . collect ( )
606
606
} else {
607
- vec ! [ crate_name. clone ( ) , relative. next_back( ) . unwrap( ) ]
607
+ vec ! [ crate_name, relative. next_back( ) . unwrap( ) ]
608
608
} ;
609
609
if path. len ( ) < 2 {
610
610
// The minimum we can have is the crate name followed by the macro name. If shorter, then
@@ -614,17 +614,22 @@ fn generate_macro_def_id_path(
614
614
}
615
615
616
616
if let Some ( last) = path. last_mut ( ) {
617
- * last = format ! ( "macro.{}.html" , last) ;
617
+ * last = Symbol :: intern ( & format ! ( "macro.{}.html" , last. as_str ( ) ) ) ;
618
618
}
619
619
620
620
let url = match cache. extern_locations [ & def_id. krate ] {
621
621
ExternalLocation :: Remote ( ref s) => {
622
622
// `ExternalLocation::Remote` always end with a `/`.
623
- format ! ( "{}{}" , s, path. join( "/" ) )
623
+ format ! ( "{}{}" , s, path. iter ( ) . map ( |p| p . as_str ( ) ) . join( "/" ) )
624
624
}
625
625
ExternalLocation :: Local => {
626
626
// `root_path` always end with a `/`.
627
- format ! ( "{}{}/{}" , root_path. unwrap_or( "" ) , crate_name, path. join( "/" ) )
627
+ format ! (
628
+ "{}{}/{}" ,
629
+ root_path. unwrap_or( "" ) ,
630
+ crate_name,
631
+ path. iter( ) . map( |p| p. as_str( ) ) . join( "/" )
632
+ )
628
633
}
629
634
ExternalLocation :: Unknown => {
630
635
debug ! ( "crate {} not in cache when linkifying macros" , crate_name) ;
@@ -1050,7 +1055,7 @@ fn fmt_type<'cx>(
1050
1055
_ => String :: new ( ) ,
1051
1056
} ;
1052
1057
let m = mutability. print_with_space ( ) ;
1053
- let amp = if f. alternate ( ) { "&" . to_string ( ) } else { "&" . to_string ( ) } ;
1058
+ let amp = if f. alternate ( ) { "&" } else { "&" } ;
1054
1059
match * * ty {
1055
1060
clean:: DynTrait ( ref bounds, ref trait_lt)
1056
1061
if bounds. len ( ) > 1 || trait_lt. is_some ( ) =>
0 commit comments