don't clone copy types

This commit is contained in:
Matthias Krüger 2020-12-29 19:33:48 +01:00
parent 158f8d034b
commit 17a8c1017f
6 changed files with 10 additions and 10 deletions

View File

@ -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() }
}
}

View File

@ -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 },
});
}
@ -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));
}

View File

@ -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
@ -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)],
})
}

View File

@ -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)
}));
}
@ -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();

View File

@ -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('/') {
@ -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;
}

View File

@ -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());
}