File tree 1 file changed +7
-7
lines changed
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>(
1502
1502
tcx : TyCtxt < ' tcx > ,
1503
1503
item_did : DefId ,
1504
1504
) -> 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 ( ) ,
1508
1508
Some ( ty:: Visibility :: Restricted ( vis_did) ) => {
1509
1509
// FIXME(camelid): This may not work correctly if `item_did` is a module.
1510
1510
// However, rustdoc currently never displays a module's
1511
1511
// visibility, so it shouldn't matter.
1512
1512
let parent_module = find_nearest_parent_module ( tcx, item_did) ;
1513
1513
1514
1514
if vis_did. is_crate_root ( ) {
1515
- "pub(crate) " . to_owned ( )
1515
+ "pub(crate) " . into ( )
1516
1516
} else if parent_module == Some ( vis_did) {
1517
1517
// `pub(in foo)` where `foo` is the parent module
1518
1518
// is the same as no visibility modifier
1519
- String :: new ( )
1519
+ "" . into ( )
1520
1520
} else if parent_module. and_then ( |parent| find_nearest_parent_module ( tcx, parent) )
1521
1521
== Some ( vis_did)
1522
1522
{
1523
- "pub(super) " . to_owned ( )
1523
+ "pub(super) " . into ( )
1524
1524
} else {
1525
- format ! ( "pub(in {}) " , tcx. def_path_str( vis_did) )
1525
+ format ! ( "pub(in {}) " , tcx. def_path_str( vis_did) ) . into ( )
1526
1526
}
1527
1527
}
1528
1528
} ;
You can’t perform that action at this time.
0 commit comments