1+ use std:: borrow:: Cow ;
12use std:: cmp:: Ordering ;
23use std:: fmt:: { self , Display , Write as _} ;
34use std:: iter;
@@ -395,25 +396,26 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
395396 let ( stab_tags, deprecation) = match import. source . did {
396397 Some ( import_def_id) => {
397398 let stab_tags =
398- print_extra_info_tags ( tcx, myitem, item, Some ( import_def_id) )
399- . to_string ( ) ;
399+ print_extra_info_tags ( tcx, myitem, item, Some ( import_def_id) ) ;
400400 let deprecation = tcx
401401 . lookup_deprecation ( import_def_id)
402402 . is_some_and ( |deprecation| deprecation. is_in_effect ( ) ) ;
403- ( stab_tags, deprecation)
403+ ( Some ( stab_tags) , deprecation)
404404 }
405- None => ( String :: new ( ) , item. is_deprecated ( tcx) ) ,
405+ None => ( None , item. is_deprecated ( tcx) ) ,
406406 } ;
407407 let visibility_and_hidden = visibility_and_hidden ( myitem) ;
408408 let id = match import. kind {
409- clean:: ImportKind :: Simple ( s) => {
410- format ! ( " id=\" {}\" " , cx. derive_id( format!( "reexport.{s}" ) ) )
411- }
412- clean:: ImportKind :: Glob => String :: new ( ) ,
409+ clean:: ImportKind :: Simple ( s) => Some ( format_args ! (
410+ " id=\" {}\" " ,
411+ cx. derive_id( format!( "reexport.{s}" ) )
412+ ) ) ,
413+ clean:: ImportKind :: Glob => None ,
413414 } ;
414415 write ! (
415416 w,
416417 "<dt{id}{deprecation_attr}><code>" ,
418+ id = id. maybe_display( ) ,
417419 deprecation_attr = deprecation_class_attr( deprecation)
418420 ) ?;
419421 write ! (
@@ -423,6 +425,7 @@ fn item_module(cx: &Context<'_>, item: &clean::Item, items: &[clean::Item]) -> i
423425 vis = visibility_print_with_space( myitem, cx) ,
424426 imp = print_import( import, cx) ,
425427 visibility_and_hidden = visibility_and_hidden,
428+ stab_tags = stab_tags. maybe_display( ) ,
426429 ) ?;
427430 }
428431 _ => {
@@ -512,18 +515,14 @@ fn print_extra_info_tags(
512515 write ! ( f, "{}" , tag_html( "unstable" , "" , "Experimental" ) ) ?;
513516 }
514517
518+ debug ! ( name = ?item. name, cfg = ?item. cfg, parent_cfg = ?parent. cfg, "Portability" ) ;
519+
515520 let cfg = match ( & item. cfg , parent. cfg . as_ref ( ) ) {
516- ( Some ( cfg) , Some ( parent_cfg) ) => cfg. simplify_with ( parent_cfg) ,
517- ( cfg, _) => cfg. as_deref ( ) . cloned ( ) ,
521+ ( Some ( cfg) , Some ( parent_cfg) ) => cfg. simplify_with ( parent_cfg) . map ( Cow :: Owned ) ,
522+ ( cfg, _) => cfg. as_deref ( ) . map ( Cow :: Borrowed ) ,
518523 } ;
519524
520- debug ! (
521- "Portability name={name:?} {cfg:?} - {parent_cfg:?} = {cfg:?}" ,
522- name = item. name,
523- cfg = item. cfg,
524- parent_cfg = parent. cfg
525- ) ;
526- if let Some ( ref cfg) = cfg {
525+ if let Some ( cfg) = cfg {
527526 write ! (
528527 f,
529528 "{}" ,
@@ -976,7 +975,7 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt:
976975 "Dyn Compatibility" ,
977976 "dyn-compatibility" ,
978977 None ,
979- format !(
978+ format_args !(
980979 "<div class=\" dyn-compatibility-info\" ><p>This trait {} \
981980 <a href=\" {base}/reference/items/traits.html#dyn-compatibility\" >dyn compatible</a>.</p>\
982981 <p><i>In older versions of Rust, dyn compatibility was called \" object safety\" .</i></p></div>",
@@ -1775,10 +1774,10 @@ fn item_variants(
17751774 w,
17761775 "{}" ,
17771776 write_section_heading(
1778- & format !( "Variants{}" , document_non_exhaustive_header( it) ) ,
1777+ format_args !( "Variants{}" , document_non_exhaustive_header( it) ) ,
17791778 "variants" ,
17801779 Some ( "variants" ) ,
1781- format !( "{}<div class=\" variants\" >" , document_non_exhaustive( it) ) ,
1780+ format_args !( "{}<div class=\" variants\" >" , document_non_exhaustive( it) ) ,
17821781 ) ,
17831782 ) ?;
17841783
@@ -2105,20 +2104,15 @@ fn item_fields(
21052104 if let None | Some ( CtorKind :: Fn ) = ctor_kind
21062105 && fields. peek ( ) . is_some ( )
21072106 {
2108- let title = format ! (
2107+ let title = format_args ! (
21092108 "{}{}" ,
21102109 if ctor_kind. is_none( ) { "Fields" } else { "Tuple Fields" } ,
21112110 document_non_exhaustive_header( it) ,
21122111 ) ;
21132112 write ! (
21142113 w,
21152114 "{}" ,
2116- write_section_heading(
2117- & title,
2118- "fields" ,
2119- Some ( "fields" ) ,
2120- document_non_exhaustive( it)
2121- )
2115+ write_section_heading( title, "fields" , Some ( "fields" ) , document_non_exhaustive( it) )
21222116 ) ?;
21232117 for ( index, ( field, ty) ) in fields. enumerate ( ) {
21242118 let field_name =
@@ -2554,7 +2548,7 @@ fn render_struct_fields(
25542548 }
25552549 for field in fields {
25562550 if let clean:: StructFieldItem ( ref ty) = field. kind {
2557- render_attributes_in_code ( w, field, & format ! ( "{tab} " ) , cx) ?;
2551+ render_attributes_in_code ( w, field, format_args ! ( "{tab} " ) , cx) ?;
25582552 writeln ! (
25592553 w,
25602554 "{tab} {vis}{name}: {ty}," ,
0 commit comments