mirror of
https://github.com/rust-lang/cargo
synced 2024-08-25 02:25:46 +00:00
Cleanup: Remove redundant clones.
This commit is contained in:
parent
ef0b47769b
commit
a91a12b4af
|
@ -2,6 +2,7 @@
|
|||
#![allow(clippy::too_many_arguments)] // large project
|
||||
#![allow(clippy::redundant_closure)] // there's a false positive
|
||||
#![warn(clippy::needless_borrow)]
|
||||
#![warn(clippy::redundant_clone)]
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::env;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#![allow(clippy::type_complexity)] // there's an exceptionally complex type
|
||||
#![allow(clippy::wrong_self_convention)] // perhaps `Rc` should be special-cased in Clippy?
|
||||
#![warn(clippy::needless_borrow)]
|
||||
#![warn(clippy::redundant_clone)]
|
||||
|
||||
use std::fmt;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ fn metadata_no_deps(ws: &Workspace<'_>, _opt: &OutputMetadataOptions) -> CargoRe
|
|||
packages: ws.members().cloned().collect(),
|
||||
workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(),
|
||||
resolve: None,
|
||||
target_directory: ws.target_dir().clone().into_path_unlocked(),
|
||||
target_directory: ws.target_dir().into_path_unlocked(),
|
||||
version: VERSION,
|
||||
workspace_root: ws.root().to_path_buf(),
|
||||
})
|
||||
|
@ -70,7 +70,7 @@ fn metadata_full(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> CargoResult
|
|||
resolve: (packages, resolve),
|
||||
root: ws.current_opt().map(|pkg| pkg.package_id()),
|
||||
}),
|
||||
target_directory: ws.target_dir().clone().into_path_unlocked(),
|
||||
target_directory: ws.target_dir().into_path_unlocked(),
|
||||
version: VERSION,
|
||||
workspace_root: ws.root().to_path_buf(),
|
||||
})
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#![allow(clippy::blacklisted_name)]
|
||||
#![allow(clippy::explicit_iter_loop)]
|
||||
#![warn(clippy::needless_borrow)]
|
||||
#![warn(clippy::redundant_clone)]
|
||||
|
||||
#[macro_use]
|
||||
mod support;
|
||||
|
|
|
@ -580,7 +580,7 @@ fn override_self() {
|
|||
.build();
|
||||
|
||||
let p = project();
|
||||
let root = p.root().clone();
|
||||
let root = p.root();
|
||||
let p = p
|
||||
.file(".cargo/config", &format!("paths = ['{}']", root.display()))
|
||||
.file(
|
||||
|
|
|
@ -340,7 +340,7 @@ fn public_dependency_skiping() {
|
|||
pkg!(("b", "0.2.1") => [dep_req_kind("a", "0.2.0", Kind::Normal, true)]),
|
||||
pkg!("c" => [dep("a"),dep("b")]),
|
||||
];
|
||||
let reg = registry(input.clone());
|
||||
let reg = registry(input);
|
||||
|
||||
resolve(pkg_id("root"), vec![dep("c")], ®).unwrap();
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ fn public_dependency_skiping_in_backtracking() {
|
|||
pkg!("B" => [dep_req_kind("A", ">= 0.0.3", Kind::Normal, true)]),
|
||||
pkg!("C" => [dep_req("A", "<= 0.0.4"), dep("B")]),
|
||||
];
|
||||
let reg = registry(input.clone());
|
||||
let reg = registry(input);
|
||||
|
||||
resolve(pkg_id("root"), vec![dep("C")], ®).unwrap();
|
||||
}
|
||||
|
@ -886,7 +886,7 @@ fn resolving_with_many_equivalent_backtracking() {
|
|||
]),
|
||||
);
|
||||
|
||||
let reg = registry(reglist.clone());
|
||||
let reg = registry(reglist);
|
||||
|
||||
let res = resolve(
|
||||
pkg_id("root"),
|
||||
|
@ -929,7 +929,7 @@ fn resolving_with_deep_traps() {
|
|||
}
|
||||
}
|
||||
|
||||
let reg = registry(reglist.clone());
|
||||
let reg = registry(reglist);
|
||||
|
||||
let res = resolve(
|
||||
pkg_id("root"),
|
||||
|
@ -1011,7 +1011,7 @@ fn resolving_with_constrained_cousins_backtrack() {
|
|||
]),
|
||||
);
|
||||
|
||||
let reg = registry(reglist.clone());
|
||||
let reg = registry(reglist);
|
||||
|
||||
let res = resolve(
|
||||
pkg_id("root"),
|
||||
|
@ -1404,6 +1404,6 @@ fn conflict_store_bug() {
|
|||
]),
|
||||
];
|
||||
|
||||
let reg = registry(input.clone());
|
||||
let reg = registry(input);
|
||||
let _ = resolve_and_validated(pkg_id("root"), vec![dep("j")], ®);
|
||||
}
|
||||
|
|
|
@ -518,7 +518,7 @@ pub fn main_file(println: &str, deps: &[&str]) -> String {
|
|||
buf.push_str(println);
|
||||
buf.push_str("); }\n");
|
||||
|
||||
buf.to_string()
|
||||
buf
|
||||
}
|
||||
|
||||
trait ErrMsg<T> {
|
||||
|
|
|
@ -34,12 +34,12 @@ pub fn resolve_and_validated(
|
|||
registry: &[Summary],
|
||||
) -> CargoResult<Vec<PackageId>> {
|
||||
let resolve = resolve_with_config_raw(pkg, deps, registry, None)?;
|
||||
let mut stack = vec![pkg.clone()];
|
||||
let mut stack = vec![pkg];
|
||||
let mut used = HashSet::new();
|
||||
let mut links = HashSet::new();
|
||||
while let Some(p) = stack.pop() {
|
||||
assert!(resolve.contains(&p));
|
||||
if used.insert(p.clone()) {
|
||||
if used.insert(p) {
|
||||
// in the tests all `links` crates end in `-sys`
|
||||
if p.name().ends_with("-sys") {
|
||||
assert!(links.insert(p.name()));
|
||||
|
@ -48,7 +48,7 @@ pub fn resolve_and_validated(
|
|||
for d in deps {
|
||||
assert!(d.matches_id(dp));
|
||||
}
|
||||
dp.clone()
|
||||
dp
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
@ -99,7 +99,7 @@ pub fn resolve_with_config_raw(
|
|||
}
|
||||
let mut registry = MyRegistry(registry);
|
||||
let summary = Summary::new(
|
||||
pkg.clone(),
|
||||
pkg,
|
||||
deps,
|
||||
&BTreeMap::<String, Vec<String>>::new(),
|
||||
None::<String>,
|
||||
|
@ -146,7 +146,7 @@ pub trait ToPkgId {
|
|||
|
||||
impl ToPkgId for PackageId {
|
||||
fn to_pkgid(&self) -> PackageId {
|
||||
self.clone()
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue