Skip to content

Commit 4f1f1a2

Browse files
committed
Avoid some unnecessary cloning.
1 parent 750f57f commit 4f1f1a2

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

src/librustdoc/clean/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl From<DefId> for ItemId {
106106
}
107107

108108
/// The crate currently being documented.
109-
#[derive(Clone, Debug)]
109+
#[derive(Debug)]
110110
pub(crate) struct Crate {
111111
pub(crate) module: Item,
112112
/// Only here so that they can be filtered through the rustdoc passes.

src/librustdoc/html/layout.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use super::static_files::{STATIC_FILES, StaticFiles};
88
use crate::externalfiles::ExternalHtml;
99
use crate::html::render::{StylePath, ensure_trailing_slash};
1010

11-
#[derive(Clone)]
1211
pub(crate) struct Layout {
1312
pub(crate) logo: String,
1413
pub(crate) favicon: String,

src/librustdoc/html/markdown.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ fn slugify(c: char) -> Option<char> {
195195
}
196196
}
197197

198-
#[derive(Clone, Debug)]
198+
#[derive(Debug)]
199199
pub struct Playground {
200200
pub crate_name: Option<Symbol>,
201201
pub url: String,

src/librustdoc/html/render/mod.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2530,7 +2530,7 @@ fn item_ty_to_section(ty: ItemType) -> ItemSection {
25302530
/// types are re-exported, we don't use the corresponding
25312531
/// entry from the js file, as inlining will have already
25322532
/// picked up the impl
2533-
fn collect_paths_for_type(first_ty: clean::Type, cache: &Cache) -> Vec<String> {
2533+
fn collect_paths_for_type(first_ty: &clean::Type, cache: &Cache) -> Vec<String> {
25342534
let mut out = Vec::new();
25352535
let mut visited = FxHashSet::default();
25362536
let mut work = VecDeque::new();
@@ -2547,7 +2547,7 @@ fn collect_paths_for_type(first_ty: clean::Type, cache: &Cache) -> Vec<String> {
25472547
work.push_back(first_ty);
25482548

25492549
while let Some(ty) = work.pop_front() {
2550-
if !visited.insert(ty.clone()) {
2550+
if !visited.insert(ty) {
25512551
continue;
25522552
}
25532553

@@ -2557,16 +2557,16 @@ fn collect_paths_for_type(first_ty: clean::Type, cache: &Cache) -> Vec<String> {
25572557
work.extend(tys.into_iter());
25582558
}
25592559
clean::Type::Slice(ty) => {
2560-
work.push_back(*ty);
2560+
work.push_back(ty);
25612561
}
25622562
clean::Type::Array(ty, _) => {
2563-
work.push_back(*ty);
2563+
work.push_back(ty);
25642564
}
25652565
clean::Type::RawPointer(_, ty) => {
2566-
work.push_back(*ty);
2566+
work.push_back(ty);
25672567
}
25682568
clean::Type::BorrowedRef { type_, .. } => {
2569-
work.push_back(*type_);
2569+
work.push_back(type_);
25702570
}
25712571
clean::Type::QPath(box clean::QPathData { self_type, trait_, .. }) => {
25722572
work.push_back(self_type);

src/librustdoc/html/render/print_item.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,7 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt:
659659
let count_types = required_types.len() + provided_types.len();
660660
let count_consts = required_consts.len() + provided_consts.len();
661661
let count_methods = required_methods.len() + provided_methods.len();
662-
let must_implement_one_of_functions = tcx.trait_def(t.def_id).must_implement_one_of.clone();
662+
let must_implement_one_of_functions = &tcx.trait_def(t.def_id).must_implement_one_of;
663663

664664
// Output the trait definition
665665
wrap_item(w, |mut w| {
@@ -1095,7 +1095,7 @@ fn item_trait(cx: &Context<'_>, it: &clean::Item, t: &clean::Trait) -> impl fmt:
10951095
it,
10961096
&implementor_dups,
10971097
&collect_paths_for_type(
1098-
implementor.inner_impl().for_.clone(),
1098+
&implementor.inner_impl().for_,
10991099
&cx.shared.cache,
11001100
),
11011101
)

src/librustdoc/html/render/write_shared.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,7 +760,7 @@ impl TraitAliasPart {
760760
Some(Implementor {
761761
text: imp.inner_impl().print(false, cx).to_string(),
762762
synthetic: imp.inner_impl().kind.is_auto(),
763-
types: collect_paths_for_type(imp.inner_impl().for_.clone(), cache),
763+
types: collect_paths_for_type(&imp.inner_impl().for_, cache),
764764
})
765765
}
766766
})

0 commit comments

Comments
 (0)