Skip to content

Commit

Permalink
don't clone copy types
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskrgr committed Dec 29, 2020
1 parent 158f8d0 commit 17a8c10
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/lib.rs
Expand Up @@ -116,7 +116,7 @@ pub struct NativeLib {

impl From<&cstore::NativeLib> for NativeLib {
fn from(lib: &cstore::NativeLib) -> Self {
NativeLib { kind: lib.kind.clone(), name: lib.name.clone(), cfg: lib.cfg.clone() }
NativeLib { kind: lib.kind, name: lib.name, cfg: lib.cfg.clone() }
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/auto_trait.rs
Expand Up @@ -597,7 +597,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
ref mut bindings, ..
} => {
bindings.push(TypeBinding {
name: left_name.clone(),
name: left_name,
kind: TypeBindingKind::Equality { ty: rhs },
});
}
Expand Down Expand Up @@ -665,7 +665,7 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
GenericParamDefKind::Type { ref mut default, ref mut bounds, .. } => {
// We never want something like `impl<T=Foo>`.
default.take();
let generic_ty = Type::Generic(param.name.clone());
let generic_ty = Type::Generic(param.name);
if !has_sized.contains(&generic_ty) {
bounds.insert(0, GenericBound::maybe_sized(self.cx));
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/mod.rs
Expand Up @@ -831,7 +831,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
where_predicates.retain(|pred| match *pred {
WP::BoundPredicate { ty: Generic(ref g), ref bounds } => {
if bounds.iter().any(|b| b.is_sized_bound(cx)) {
sized_params.insert(g.clone());
sized_params.insert(*g);
false
} else {
true
Expand All @@ -847,7 +847,7 @@ impl<'a, 'tcx> Clean<Generics> for (&'a ty::Generics, ty::GenericPredicates<'tcx
&& !sized_params.contains(&tp.name)
{
where_predicates.push(WP::BoundPredicate {
ty: Type::Generic(tp.name.clone()),
ty: Type::Generic(tp.name),
bounds: vec![GenericBound::maybe_sized(cx)],
})
}
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/clean/utils.rs
Expand Up @@ -74,7 +74,7 @@ crate fn krate(mut cx: &mut DocContext<'_>) -> Crate {
)
}));
m.items.extend(keywords.into_iter().map(|(def_id, kw)| {
Item::from_def_id_and_parts(def_id, Some(kw.clone()), ItemKind::KeywordItem(kw), cx)
Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::KeywordItem(kw), cx)
}));
}

Expand Down Expand Up @@ -307,7 +307,7 @@ crate fn strip_path(path: &Path) -> Path {
.segments
.iter()
.map(|s| PathSegment {
name: s.name.clone(),
name: s.name,
args: GenericArgs::AngleBracketed { args: vec![], bindings: vec![] },
})
.collect();
Expand Down
4 changes: 2 additions & 2 deletions src/librustdoc/html/render/mod.rs
Expand Up @@ -538,7 +538,7 @@ impl<'tcx> FormatRenderer<'tcx> for Context<'tcx> {
fn after_krate(&mut self, krate: &clean::Crate, cache: &Cache) -> Result<(), Error> {
let final_file = self.dst.join(&*krate.name.as_str()).join("all.html");
let settings_file = self.dst.join("settings.html");
let crate_name = krate.name.clone();
let crate_name = krate.name;

let mut root_path = self.dst.to_str().expect("invalid path").to_owned();
if !root_path.ends_with('/') {
Expand Down Expand Up @@ -3967,7 +3967,7 @@ fn render_impl(
cache: &Cache,
) {
for trait_item in &t.items {
let n = trait_item.name.clone();
let n = trait_item.name;
if i.items.iter().any(|m| m.name == n) {
continue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustdoc/passes/collect_intra_doc_links.rs
Expand Up @@ -1234,7 +1234,7 @@ impl LinkCollector<'_, '_> {
) -> Option<(Res, Option<String>)> {
// Try to look up both the result and the corresponding side channel value
if let Some(ref cached) = self.visited_links.get(&key) {
self.kind_side_channel.set(cached.side_channel.clone());
self.kind_side_channel.set(cached.side_channel);
return Some(cached.res.clone());
}

Expand Down

0 comments on commit 17a8c10

Please sign in to comment.