File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -1502,27 +1502,27 @@ pub(crate) fn visibility_to_src_with_space<'a, 'tcx: 'a>(
15021502 tcx : TyCtxt < ' tcx > ,
15031503 item_did : DefId ,
15041504) -> impl fmt:: Display + ' a + Captures < ' tcx > {
1505- let to_print = match visibility {
1506- None => String :: new ( ) ,
1507- Some ( ty:: Visibility :: Public ) => "pub " . to_owned ( ) ,
1505+ let to_print: Cow < ' static , str > = match visibility {
1506+ None => "" . into ( ) ,
1507+ Some ( ty:: Visibility :: Public ) => "pub " . into ( ) ,
15081508 Some ( ty:: Visibility :: Restricted ( vis_did) ) => {
15091509 // FIXME(camelid): This may not work correctly if `item_did` is a module.
15101510 // However, rustdoc currently never displays a module's
15111511 // visibility, so it shouldn't matter.
15121512 let parent_module = find_nearest_parent_module ( tcx, item_did) ;
15131513
15141514 if vis_did. is_crate_root ( ) {
1515- "pub(crate) " . to_owned ( )
1515+ "pub(crate) " . into ( )
15161516 } else if parent_module == Some ( vis_did) {
15171517 // `pub(in foo)` where `foo` is the parent module
15181518 // is the same as no visibility modifier
1519- String :: new ( )
1519+ "" . into ( )
15201520 } else if parent_module. and_then ( |parent| find_nearest_parent_module ( tcx, parent) )
15211521 == Some ( vis_did)
15221522 {
1523- "pub(super) " . to_owned ( )
1523+ "pub(super) " . into ( )
15241524 } else {
1525- format ! ( "pub(in {}) " , tcx. def_path_str( vis_did) )
1525+ format ! ( "pub(in {}) " , tcx. def_path_str( vis_did) ) . into ( )
15261526 }
15271527 }
15281528 } ;
You can’t perform that action at this time.
0 commit comments