Skip to content

Commit 28fb200

Browse files
committedDec 9, 2018
Auto merge of #6407 - sinkuu:redundant_clone, r=dwijnand
Remove redundant clones
2 parents a6b2148 + 35a2b86 commit 28fb200

File tree

7 files changed

+9
-9
lines changed

7 files changed

+9
-9
lines changed
 

‎src/cargo/core/compiler/build_config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl BuildConfig {
6565
}
6666
}
6767
let cfg_target = config.get_string("build.target")?.map(|s| s.val);
68-
let target = requested_target.clone().or(cfg_target);
68+
let target = requested_target.or(cfg_target);
6969

7070
if jobs == Some(0) {
7171
bail!("jobs must be at least 1")

‎src/cargo/core/registry.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ fn lock(locked: &LockedMap, patches: &HashMap<Url, Vec<PackageId>>, summary: Sum
594594
let locked = locked_deps.iter().find(|&&id| dep.matches_id(id));
595595
if let Some(&locked) = locked {
596596
trace!("\tfirst hit on {}", locked);
597-
let mut dep = dep.clone();
597+
let mut dep = dep;
598598
dep.lock_to(locked);
599599
return dep;
600600
}
@@ -609,7 +609,7 @@ fn lock(locked: &LockedMap, patches: &HashMap<Url, Vec<PackageId>>, summary: Sum
609609
.and_then(|vec| vec.iter().find(|&&(id, _)| dep.matches_id(id)));
610610
if let Some(&(id, _)) = v {
611611
trace!("\tsecond hit on {}", id);
612-
let mut dep = dep.clone();
612+
let mut dep = dep;
613613
dep.lock_to(id);
614614
return dep;
615615
}
@@ -635,7 +635,7 @@ fn lock(locked: &LockedMap, patches: &HashMap<Url, Vec<PackageId>>, summary: Sum
635635
if patch_locked {
636636
trace!("\tthird hit on {}", patch_id);
637637
let req = VersionReq::exact(patch_id.version());
638-
let mut dep = dep.clone();
638+
let mut dep = dep;
639639
dep.set_version_req(req);
640640
return dep;
641641
}

‎src/cargo/core/resolver/resolve.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ unable to verify that `{0}` is the same as when the lockfile was generated
250250
to
251251
);
252252
}
253-
Ok(name.to_string())
253+
Ok(name)
254254
}
255255

256256
fn dependencies_listed(&self, from: PackageId, to: PackageId) -> &[Dependency] {

‎src/cargo/ops/cargo_run.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ pub fn run(
8383
let exe = &compile.binaries[0];
8484
let exe = match util::without_prefix(exe, config.cwd()) {
8585
Some(path) if path.file_name() == Some(path.as_os_str()) => {
86-
Path::new(".").join(path).to_path_buf()
86+
Path::new(".").join(path)
8787
}
8888
Some(path) => path.to_path_buf(),
8989
None => exe.to_path_buf(),

‎src/cargo/sources/registry/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ impl<'cfg> RegistrySource<'cfg> {
464464
.chain_err(|| format!("failed to unpack entry at `{}`", entry_path.display()))?;
465465
}
466466
File::create(&ok)?;
467-
Ok(dst.clone())
467+
Ok(dst)
468468
}
469469

470470
fn do_update(&mut self) -> CargoResult<()> {

‎src/cargo/sources/registry/remote.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
230230
}
231231

232232
let config = self.config()?.unwrap();
233-
let mut url = config.dl.clone();
233+
let mut url = config.dl;
234234
if !url.contains(CRATE_TEMPLATE) && !url.contains(VERSION_TEMPLATE) {
235235
write!(url, "/{}/{}/download", CRATE_TEMPLATE, VERSION_TEMPLATE).unwrap();
236236
}

‎src/cargo/util/config.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,7 @@ impl ConfigSeqAccess {
12691269
if !(v.starts_with('[') && v.ends_with(']')) {
12701270
return Err(ConfigError::new(
12711271
format!("should have TOML list syntax, found `{}`", v),
1272-
def.clone(),
1272+
def,
12731273
));
12741274
}
12751275
let temp_key = key.last().to_env();

0 commit comments

Comments
 (0)
Please sign in to comment.