Skip to content

Commit 1f01433

Browse files
committed
clean up few alloc
1 parent 7ac4b82 commit 1f01433

File tree

4 files changed

+3
-5
lines changed

4 files changed

+3
-5
lines changed

src/librustdoc/html/format.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>(
14801480
debug!("path={:?}", path);
14811481
// modified from `resolved_path()` to work with `DefPathData`
14821482
let last_name = path.data.last().unwrap().data.get_opt_name().unwrap();
1483-
let anchor = anchor(vis_did, last_name, cx).to_string();
1483+
let anchor = anchor(vis_did, last_name, cx);
14841484

14851485
let mut s = "pub(in ".to_owned();
14861486
for seg in &path.data[..path.data.len() - 1] {

src/librustdoc/html/render/context.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl<'tcx> Context<'tcx> {
352352
},
353353
);
354354

355-
path = href.into_inner().to_string_lossy().to_string();
355+
path = href.into_inner().to_string_lossy().into_owned();
356356

357357
if let Some(c) = path.as_bytes().last() && *c != b'/' {
358358
path.push('/');

src/librustdoc/html/sources.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ impl LocalSourcesCollector<'_, '_> {
8585
},
8686
);
8787

88-
let mut href = href.into_inner().to_string_lossy().to_string();
88+
let mut href = href.into_inner().to_string_lossy().into_owned();
8989
if let Some(c) = href.as_bytes().last() && *c != b'/' {
9090
href.push('/');
9191
}

src/librustdoc/passes/collect_intra_doc_links.rs

-2
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
286286
split.next().map(|f| Symbol::intern(f)).ok_or_else(no_res)?;
287287
let path = split
288288
.next()
289-
.map(|f| f.to_owned())
290289
// If there's no third component, we saw `[a::b]` before and it failed to resolve.
291290
// So there's no partial res.
292291
.ok_or_else(no_res)?;
@@ -429,7 +428,6 @@ impl<'a, 'tcx> LinkCollector<'a, 'tcx> {
429428
let item_name = Symbol::intern(item_str);
430429
let path_root = split
431430
.next()
432-
.map(|f| f.to_owned())
433431
// If there's no `::`, it's not an associated item.
434432
// So we can be sure that `rustc_resolve` was accurate when it said it wasn't resolved.
435433
.ok_or_else(|| {

0 commit comments

Comments
 (0)