mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Cleanup: Remove unnecessary borrows.
This commit is contained in:
parent
a57b96dc52
commit
ef0b47769b
@ -47,7 +47,7 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'"
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
if let Some(ref code) = args.value_of("explain") {
|
||||
if let Some(code) = args.value_of("explain") {
|
||||
let mut procss = config.rustc(None)?.process();
|
||||
procss.arg("--explain").arg(code).exec()?;
|
||||
return Ok(());
|
||||
|
@ -1,6 +1,7 @@
|
||||
#![warn(rust_2018_idioms)] // while we're getting used to 2018
|
||||
#![allow(clippy::too_many_arguments)] // large project
|
||||
#![allow(clippy::redundant_closure)] // there's a false positive
|
||||
#![warn(clippy::needless_borrow)]
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::env;
|
||||
|
@ -113,7 +113,7 @@ impl BuildPlan {
|
||||
let id = self.plan.invocations.len();
|
||||
self.invocation_map.insert(unit.buildkey(), id);
|
||||
let deps = cx
|
||||
.dep_targets(&unit)
|
||||
.dep_targets(unit)
|
||||
.iter()
|
||||
.map(|dep| self.invocation_map[&dep.buildkey()])
|
||||
.collect();
|
||||
|
@ -120,7 +120,7 @@ impl<'cfg> Compilation<'cfg> {
|
||||
rustc_process: rustc,
|
||||
host: bcx.host_triple().to_string(),
|
||||
target: bcx.target_triple().to_string(),
|
||||
target_runner: target_runner(&bcx)?,
|
||||
target_runner: target_runner(bcx)?,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -491,7 +491,7 @@ fn compute_metadata<'a, 'cfg>(
|
||||
// settings like debuginfo and whatnot.
|
||||
unit.profile.hash(&mut hasher);
|
||||
unit.mode.hash(&mut hasher);
|
||||
if let Some(ref args) = bcx.extra_args_for(unit) {
|
||||
if let Some(args) = bcx.extra_args_for(unit) {
|
||||
args.hash(&mut hasher);
|
||||
}
|
||||
|
||||
|
@ -474,11 +474,11 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
||||
for unit in keys {
|
||||
for output in self.outputs(unit)?.iter() {
|
||||
if let Some(other_unit) = output_collisions.insert(output.path.clone(), unit) {
|
||||
report_collision(unit, &other_unit, &output.path)?;
|
||||
report_collision(unit, other_unit, &output.path)?;
|
||||
}
|
||||
if let Some(hardlink) = output.hardlink.as_ref() {
|
||||
if let Some(other_unit) = output_collisions.insert(hardlink.clone(), unit) {
|
||||
report_collision(unit, &other_unit, hardlink)?;
|
||||
report_collision(unit, other_unit, hardlink)?;
|
||||
}
|
||||
}
|
||||
if let Some(ref export_path) = output.export_path {
|
||||
@ -488,7 +488,7 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
|
||||
{}\
|
||||
The exported filenames should be unique.\n\
|
||||
{}",
|
||||
describe_collision(unit, &other_unit, &export_path),
|
||||
describe_collision(unit, other_unit, export_path),
|
||||
suggestion
|
||||
))?;
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes
|
||||
.env(
|
||||
"TARGET",
|
||||
&match unit.kind {
|
||||
Kind::Host => &bcx.host_triple(),
|
||||
Kind::Host => bcx.host_triple(),
|
||||
Kind::Target => bcx.target_triple(),
|
||||
},
|
||||
)
|
||||
|
@ -682,7 +682,7 @@ fn calculate<'a, 'cfg>(
|
||||
local.extend(local_fingerprint_run_custom_build_deps(cx, unit));
|
||||
local
|
||||
} else {
|
||||
let fingerprint = pkg_fingerprint(&cx.bcx, unit.pkg)?;
|
||||
let fingerprint = pkg_fingerprint(cx.bcx, unit.pkg)?;
|
||||
vec![LocalFingerprint::Precalculated(fingerprint)]
|
||||
};
|
||||
|
||||
@ -701,7 +701,7 @@ fn calculate<'a, 'cfg>(
|
||||
profile: profile_hash,
|
||||
// Note that .0 is hashed here, not .1 which is the cwd. That doesn't
|
||||
// actually affect the output artifact so there's no need to hash it.
|
||||
path: util::hash_u64(&super::path_args(&cx.bcx, unit).0),
|
||||
path: util::hash_u64(&super::path_args(cx.bcx, unit).0),
|
||||
features: format!("{:?}", bcx.resolve.features_sorted(unit.pkg.package_id())),
|
||||
deps,
|
||||
local,
|
||||
@ -855,7 +855,7 @@ fn build_script_local_fingerprints<'a, 'cfg>(
|
||||
let output = deps.build_script_output.clone();
|
||||
if deps.rerun_if_changed.is_empty() && deps.rerun_if_env_changed.is_empty() {
|
||||
debug!("old local fingerprints deps");
|
||||
let s = pkg_fingerprint(&cx.bcx, unit.pkg)?;
|
||||
let s = pkg_fingerprint(cx.bcx, unit.pkg)?;
|
||||
return Ok((vec![LocalFingerprint::Precalculated(s)], Some(output)));
|
||||
}
|
||||
|
||||
|
@ -631,7 +631,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult
|
||||
|
||||
add_error_format(bcx, &mut rustdoc);
|
||||
|
||||
if let Some(ref args) = bcx.extra_args_for(unit) {
|
||||
if let Some(args) = bcx.extra_args_for(unit) {
|
||||
rustdoc.args(args);
|
||||
}
|
||||
|
||||
@ -822,7 +822,7 @@ fn build_base_args<'a, 'cfg>(
|
||||
cmd.arg("-C").arg(format!("debuginfo={}", debuginfo));
|
||||
}
|
||||
|
||||
if let Some(ref args) = bcx.extra_args_for(unit) {
|
||||
if let Some(args) = bcx.extra_args_for(unit) {
|
||||
cmd.args(args);
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ impl ser::Serialize for Package {
|
||||
|
||||
SerializedPackage {
|
||||
name: &*package_id.name(),
|
||||
version: &package_id.version(),
|
||||
version: package_id.version(),
|
||||
id: package_id,
|
||||
license,
|
||||
license_file,
|
||||
@ -740,7 +740,7 @@ impl<'a, 'cfg> Downloads<'a, 'cfg> {
|
||||
self.set.multi.messages(|msg| {
|
||||
let token = msg.token().expect("failed to read token");
|
||||
let handle = &pending[&token].1;
|
||||
if let Some(result) = msg.result_for(&handle) {
|
||||
if let Some(result) = msg.result_for(handle) {
|
||||
results.push((token, result));
|
||||
} else {
|
||||
debug!("message without a result (?)");
|
||||
|
@ -368,7 +368,7 @@ impl PartialOrd for SourceId {
|
||||
|
||||
impl Ord for SourceId {
|
||||
fn cmp(&self, other: &SourceId) -> Ordering {
|
||||
self.inner.cmp(&other.inner)
|
||||
self.inner.cmp(other.inner)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,7 +58,7 @@ impl Summary {
|
||||
)
|
||||
}
|
||||
}
|
||||
let feature_map = build_feature_map(&features, &dependencies, namespaced_features)?;
|
||||
let feature_map = build_feature_map(features, &dependencies, namespaced_features)?;
|
||||
Ok(Summary {
|
||||
inner: Rc::new(Inner {
|
||||
package_id: pkg_id,
|
||||
@ -170,7 +170,7 @@ where
|
||||
// iteration over the list if the dependency is found in the list.
|
||||
let mut dependency_found = if namespaced {
|
||||
match dep_map.get(feature.borrow()) {
|
||||
Some(ref dep_data) => {
|
||||
Some(dep_data) => {
|
||||
if !dep_data.iter().any(|d| d.is_optional()) {
|
||||
failure::bail!(
|
||||
"Feature `{}` includes the dependency of the same name, but this is \
|
||||
|
@ -14,6 +14,7 @@
|
||||
#![allow(clippy::too_many_arguments)] // large project
|
||||
#![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)]
|
||||
|
||||
use std::fmt;
|
||||
|
||||
|
@ -372,12 +372,12 @@ pub fn compile_ws<'a>(
|
||||
&resolve_with_overrides,
|
||||
&packages,
|
||||
config,
|
||||
&build_config,
|
||||
build_config,
|
||||
profiles,
|
||||
extra_compiler_args,
|
||||
)?;
|
||||
let cx = Context::new(config, &bcx)?;
|
||||
cx.compile(&units, export_dir.clone(), &exec)?
|
||||
cx.compile(&units, export_dir.clone(), exec)?
|
||||
};
|
||||
|
||||
Ok(ret)
|
||||
|
@ -59,7 +59,7 @@ pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult<Option
|
||||
// dirty. This will `bail!` if dirty, unless allow_dirty. Produce json
|
||||
// info for any sha1 (HEAD revision) returned.
|
||||
let vcs_info = if !opts.allow_dirty {
|
||||
check_repo_state(pkg, &src_files, &config, opts.allow_dirty)?
|
||||
check_repo_state(pkg, &src_files, config, opts.allow_dirty)?
|
||||
.map(|h| json!({"git":{"sha1": h}}))
|
||||
} else {
|
||||
None
|
||||
@ -364,7 +364,7 @@ fn tar(
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref json) = vcs_info {
|
||||
if let Some(json) = vcs_info {
|
||||
let filename: PathBuf = Path::new(VCS_INFO_FILE).into();
|
||||
debug_assert!(check_filename(&filename).is_ok());
|
||||
let fnd = filename.display();
|
||||
|
@ -147,7 +147,7 @@ fn uninstall_pkgid(
|
||||
installed.remove();
|
||||
}
|
||||
}
|
||||
write_crate_list(&crate_metadata, metadata)?;
|
||||
write_crate_list(crate_metadata, metadata)?;
|
||||
for bin in to_remove {
|
||||
config.shell().status("Removing", bin.display())?;
|
||||
paths::remove_file(bin)?;
|
||||
|
@ -238,7 +238,7 @@ fn transmit(
|
||||
.map(|(feat, values)| {
|
||||
(
|
||||
feat.to_string(),
|
||||
values.iter().map(|fv| fv.to_string(&summary)).collect(),
|
||||
values.iter().map(|fv| fv.to_string(summary)).collect(),
|
||||
)
|
||||
})
|
||||
.collect::<BTreeMap<String, Vec<String>>>();
|
||||
|
@ -434,19 +434,19 @@ about this warning.";
|
||||
compile_opts: &CompileOptions<'_>,
|
||||
) -> CargoResult<()> {
|
||||
if self.is_present_with_zero_values("example") {
|
||||
print_available_examples(&workspace, &compile_opts)?;
|
||||
print_available_examples(workspace, compile_opts)?;
|
||||
}
|
||||
|
||||
if self.is_present_with_zero_values("bin") {
|
||||
print_available_binaries(&workspace, &compile_opts)?;
|
||||
print_available_binaries(workspace, compile_opts)?;
|
||||
}
|
||||
|
||||
if self.is_present_with_zero_values("bench") {
|
||||
print_available_benches(&workspace, &compile_opts)?;
|
||||
print_available_benches(workspace, compile_opts)?;
|
||||
}
|
||||
|
||||
if self.is_present_with_zero_values("test") {
|
||||
print_available_tests(&workspace, &compile_opts)?;
|
||||
print_available_tests(workspace, compile_opts)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
@ -124,7 +124,7 @@ impl<K: Hash + Eq + Clone, V> DependencyQueue<K, V> {
|
||||
results.insert(key.clone(), IN_PROGRESS);
|
||||
|
||||
let depth = 1 + map
|
||||
.get(&key)
|
||||
.get(key)
|
||||
.into_iter()
|
||||
.flat_map(|it| it)
|
||||
.map(|dep| depth(dep, map, results))
|
||||
|
@ -835,7 +835,7 @@ impl TomlManifest {
|
||||
// Parse features first so they will be available when parsing other parts of the TOML.
|
||||
let empty = Vec::new();
|
||||
let cargo_features = me.cargo_features.as_ref().unwrap_or(&empty);
|
||||
let features = Features::new(&cargo_features, &mut warnings)?;
|
||||
let features = Features::new(cargo_features, &mut warnings)?;
|
||||
|
||||
let project = me.project.as_ref().or_else(|| me.package.as_ref());
|
||||
let project = project.ok_or_else(|| failure::format_err!("no `package` section found"))?;
|
||||
@ -1010,7 +1010,7 @@ impl TomlManifest {
|
||||
|
||||
let workspace_config = match (me.workspace.as_ref(), project.workspace.as_ref()) {
|
||||
(Some(config), None) => WorkspaceConfig::Root(WorkspaceRootConfig::new(
|
||||
&package_root,
|
||||
package_root,
|
||||
&config.members,
|
||||
&config.default_members,
|
||||
&config.exclude,
|
||||
@ -1138,7 +1138,7 @@ impl TomlManifest {
|
||||
let mut deps = Vec::new();
|
||||
let empty = Vec::new();
|
||||
let cargo_features = me.cargo_features.as_ref().unwrap_or(&empty);
|
||||
let features = Features::new(&cargo_features, &mut warnings)?;
|
||||
let features = Features::new(cargo_features, &mut warnings)?;
|
||||
|
||||
let (replace, patch) = {
|
||||
let mut cx = Context {
|
||||
@ -1157,7 +1157,7 @@ impl TomlManifest {
|
||||
let profiles = Profiles::new(me.profile.as_ref(), config, &features, &mut warnings)?;
|
||||
let workspace_config = match me.workspace {
|
||||
Some(ref config) => WorkspaceConfig::Root(WorkspaceRootConfig::new(
|
||||
&root,
|
||||
root,
|
||||
&config.members,
|
||||
&config.default_members,
|
||||
&config.exclude,
|
||||
|
@ -577,7 +577,7 @@ fn git_lock_file_doesnt_change() {
|
||||
let root = paths::root();
|
||||
t!(fs::create_dir(&root.join(".cargo")));
|
||||
t!(t!(File::create(root.join(".cargo/config"))).write_all(
|
||||
&format!(
|
||||
format!(
|
||||
r#"
|
||||
[source.my-git-repo]
|
||||
git = '{}'
|
||||
|
@ -158,7 +158,7 @@ fn cargo_compile_offline_with_cached_git_dep() {
|
||||
File::create(&prj.root().join("Cargo.toml"))
|
||||
.unwrap()
|
||||
.write_all(
|
||||
&format!(
|
||||
format!(
|
||||
r#"
|
||||
[project]
|
||||
name = "cache_git_dep"
|
||||
@ -220,7 +220,7 @@ fn cargo_compile_offline_with_cached_git_dep() {
|
||||
File::create(&p.root().join("Cargo.toml"))
|
||||
.unwrap()
|
||||
.write_all(
|
||||
&format!(
|
||||
format!(
|
||||
r#"
|
||||
[project]
|
||||
name = "foo"
|
||||
@ -2861,7 +2861,7 @@ fn templatedir_doesnt_cause_problems() {
|
||||
File::create(paths::home().join(".gitconfig"))
|
||||
.unwrap()
|
||||
.write_all(
|
||||
&format!(
|
||||
format!(
|
||||
r#"
|
||||
[init]
|
||||
templatedir = {}
|
||||
|
@ -2,6 +2,7 @@
|
||||
#![cfg_attr(feature = "deny-warnings", deny(warnings))]
|
||||
#![allow(clippy::blacklisted_name)]
|
||||
#![allow(clippy::explicit_iter_loop)]
|
||||
#![warn(clippy::needless_borrow)]
|
||||
|
||||
#[macro_use]
|
||||
mod support;
|
||||
|
@ -910,7 +910,7 @@ authors = []
|
||||
f,
|
||||
"bar-0.1.0.crate",
|
||||
&["Cargo.toml", "Cargo.toml.orig", "src/lib.rs"],
|
||||
&[("Cargo.toml", &rewritten_toml)],
|
||||
&[("Cargo.toml", rewritten_toml)],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -201,7 +201,7 @@ fn profile_override_bad_settings() {
|
||||
),
|
||||
("overrides = {}", "Profile overrides cannot be nested."),
|
||||
];
|
||||
for &(ref snippet, ref expected) in bad_values.iter() {
|
||||
for &(snippet, expected) in bad_values.iter() {
|
||||
let p = project()
|
||||
.file(
|
||||
"Cargo.toml",
|
||||
|
@ -46,7 +46,7 @@ proptest! {
|
||||
// So we try some of the most complicated.
|
||||
for this in input.iter().rev().take(20) {
|
||||
let _ = resolve_and_validated(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
®,
|
||||
);
|
||||
@ -81,13 +81,13 @@ proptest! {
|
||||
// minimal-versions change what order the candidates
|
||||
// are tried but not the existence of a solution
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
®,
|
||||
);
|
||||
|
||||
let mres = resolve_with_config(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
®,
|
||||
Some(&config),
|
||||
@ -127,13 +127,13 @@ proptest! {
|
||||
// So we try some of the most complicated.
|
||||
for this in input.iter().rev().take(10) {
|
||||
if resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
®,
|
||||
).is_ok() {
|
||||
prop_assert!(
|
||||
resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
&removed_reg,
|
||||
).is_ok(),
|
||||
@ -157,7 +157,7 @@ proptest! {
|
||||
// So we try some of the most complicated.
|
||||
for this in input.iter().rev().take(10) {
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
®,
|
||||
);
|
||||
@ -183,7 +183,7 @@ proptest! {
|
||||
);
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
&new_reg,
|
||||
);
|
||||
@ -217,7 +217,7 @@ proptest! {
|
||||
);
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
&new_reg,
|
||||
);
|
||||
@ -244,7 +244,7 @@ fn basic_public_dependency() {
|
||||
pkg!("C" => [dep("A"), dep("B")]),
|
||||
]);
|
||||
|
||||
let res = resolve_and_validated(&pkg_id("root"), vec![dep("C")], ®).unwrap();
|
||||
let res = resolve_and_validated(pkg_id("root"), vec![dep("C")], ®).unwrap();
|
||||
assert_same(
|
||||
&res,
|
||||
&names(&[
|
||||
@ -280,7 +280,7 @@ fn public_dependency_filling_in() {
|
||||
pkg!("d" => [dep("c"), dep("a"), dep("b")]),
|
||||
]);
|
||||
|
||||
let res = resolve_and_validated(&pkg_id("root"), vec![dep("d")], ®).unwrap();
|
||||
let res = resolve_and_validated(pkg_id("root"), vec![dep("d")], ®).unwrap();
|
||||
assert_same(
|
||||
&res,
|
||||
&names(&[
|
||||
@ -315,7 +315,7 @@ fn public_dependency_filling_in_and_update() {
|
||||
pkg!("C" => [dep("A"),dep("B")]),
|
||||
pkg!("D" => [dep("B"),dep("C")]),
|
||||
]);
|
||||
let res = resolve_and_validated(&pkg_id("root"), vec![dep("D")], ®).unwrap();
|
||||
let res = resolve_and_validated(pkg_id("root"), vec![dep("D")], ®).unwrap();
|
||||
assert_same(
|
||||
&res,
|
||||
&names(&[
|
||||
@ -342,7 +342,7 @@ fn public_dependency_skiping() {
|
||||
];
|
||||
let reg = registry(input.clone());
|
||||
|
||||
resolve(&pkg_id("root"), vec![dep("c")], ®).unwrap();
|
||||
resolve(pkg_id("root"), vec![dep("c")], ®).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -362,7 +362,7 @@ fn public_dependency_skiping_in_backtracking() {
|
||||
];
|
||||
let reg = registry(input.clone());
|
||||
|
||||
resolve(&pkg_id("root"), vec![dep("C")], ®).unwrap();
|
||||
resolve(pkg_id("root"), vec![dep("C")], ®).unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -374,7 +374,7 @@ fn test_dependency_with_empty_name() {
|
||||
|
||||
#[test]
|
||||
fn test_resolving_empty_dependency_list() {
|
||||
let res = resolve(&pkg_id("root"), Vec::new(), ®istry(vec![])).unwrap();
|
||||
let res = resolve(pkg_id("root"), Vec::new(), ®istry(vec![])).unwrap();
|
||||
|
||||
assert_eq!(res, names(&["root"]));
|
||||
}
|
||||
@ -382,28 +382,28 @@ fn test_resolving_empty_dependency_list() {
|
||||
#[test]
|
||||
fn test_resolving_only_package() {
|
||||
let reg = registry(vec![pkg!("foo")]);
|
||||
let res = resolve(&pkg_id("root"), vec![dep("foo")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("foo")], ®).unwrap();
|
||||
assert_same(&res, &names(&["root", "foo"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_resolving_one_dep() {
|
||||
let reg = registry(vec![pkg!("foo"), pkg!("bar")]);
|
||||
let res = resolve(&pkg_id("root"), vec![dep("foo")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("foo")], ®).unwrap();
|
||||
assert_same(&res, &names(&["root", "foo"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_resolving_multiple_deps() {
|
||||
let reg = registry(vec![pkg!("foo"), pkg!("bar"), pkg!("baz")]);
|
||||
let res = resolve(&pkg_id("root"), vec![dep("foo"), dep("baz")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("foo"), dep("baz")], ®).unwrap();
|
||||
assert_same(&res, &names(&["root", "foo", "baz"]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_resolving_transitive_deps() {
|
||||
let reg = registry(vec![pkg!("foo"), pkg!("bar" => ["foo"])]);
|
||||
let res = resolve(&pkg_id("root"), vec![dep("bar")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("bar")], ®).unwrap();
|
||||
|
||||
assert_same(&res, &names(&["root", "foo", "bar"]));
|
||||
}
|
||||
@ -411,7 +411,7 @@ fn test_resolving_transitive_deps() {
|
||||
#[test]
|
||||
fn test_resolving_common_transitive_deps() {
|
||||
let reg = registry(vec![pkg!("foo" => ["bar"]), pkg!("bar")]);
|
||||
let res = resolve(&pkg_id("root"), vec![dep("foo"), dep("bar")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("foo"), dep("bar")], ®).unwrap();
|
||||
|
||||
assert_same(&res, &names(&["root", "foo", "bar"]));
|
||||
}
|
||||
@ -425,7 +425,7 @@ fn test_resolving_with_same_name() {
|
||||
|
||||
let reg = registry(list);
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![
|
||||
dep_loc("foo", "https://first.example.com"),
|
||||
dep_loc("bar", "https://second.example.com"),
|
||||
@ -453,7 +453,7 @@ fn test_resolving_with_dev_deps() {
|
||||
]);
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep("foo"), dep_kind("baz", Kind::Development)],
|
||||
®,
|
||||
)
|
||||
@ -466,7 +466,7 @@ fn test_resolving_with_dev_deps() {
|
||||
fn resolving_with_many_versions() {
|
||||
let reg = registry(vec![pkg!(("foo", "1.0.1")), pkg!(("foo", "1.0.2"))]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep("foo")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("foo")], ®).unwrap();
|
||||
|
||||
assert_same(&res, &names(&[("root", "1.0.0"), ("foo", "1.0.2")]));
|
||||
}
|
||||
@ -475,7 +475,7 @@ fn resolving_with_many_versions() {
|
||||
fn resolving_with_specific_version() {
|
||||
let reg = registry(vec![pkg!(("foo", "1.0.1")), pkg!(("foo", "1.0.2"))]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("foo", "=1.0.1")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("foo", "=1.0.1")], ®).unwrap();
|
||||
|
||||
assert_same(&res, &names(&[("root", "1.0.0"), ("foo", "1.0.1")]));
|
||||
}
|
||||
@ -491,7 +491,7 @@ fn test_resolving_maximum_version_with_transitive_deps() {
|
||||
]);
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req("foo", "1.0.0"), dep_req("bar", "1.0.0")],
|
||||
®,
|
||||
)
|
||||
@ -539,7 +539,7 @@ fn test_resolving_minimum_version_with_transitive_deps() {
|
||||
.unwrap();
|
||||
|
||||
let res = resolve_with_config(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req("foo", "1.0.0"), dep_req("bar", "1.0.0")],
|
||||
®,
|
||||
Some(&config),
|
||||
@ -600,7 +600,7 @@ fn resolving_incompat_versions() {
|
||||
]);
|
||||
|
||||
assert!(resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req("foo", "=1.0.1"), dep("bar")],
|
||||
®
|
||||
)
|
||||
@ -615,7 +615,7 @@ fn resolving_wrong_case_from_registry() {
|
||||
// This test documents the current behavior.
|
||||
let reg = registry(vec![pkg!(("foo", "1.0.0")), pkg!("bar" => ["Foo"])]);
|
||||
|
||||
assert!(resolve(&pkg_id("root"), vec![dep("bar")], ®).is_err());
|
||||
assert!(resolve(pkg_id("root"), vec![dep("bar")], ®).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -626,7 +626,7 @@ fn resolving_mis_hyphenated_from_registry() {
|
||||
// This test documents the current behavior.
|
||||
let reg = registry(vec![pkg!(("fo-o", "1.0.0")), pkg!("bar" => ["fo_o"])]);
|
||||
|
||||
assert!(resolve(&pkg_id("root"), vec![dep("bar")], ®).is_err());
|
||||
assert!(resolve(pkg_id("root"), vec![dep("bar")], ®).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -638,7 +638,7 @@ fn resolving_backtrack() {
|
||||
pkg!("baz"),
|
||||
]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("foo", "^1")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("foo", "^1")], ®).unwrap();
|
||||
|
||||
assert_contains(
|
||||
&res,
|
||||
@ -658,7 +658,7 @@ fn resolving_backtrack_features() {
|
||||
pkg!("bar"),
|
||||
]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("foo", "^1")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("foo", "^1")], ®).unwrap();
|
||||
|
||||
assert_contains(
|
||||
&res,
|
||||
@ -680,7 +680,7 @@ fn resolving_allows_multiple_compatible_versions() {
|
||||
pkg!("d4" => [dep_req("foo", "0.2")]),
|
||||
]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep("bar")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("bar")], ®).unwrap();
|
||||
|
||||
assert_same(
|
||||
&res,
|
||||
@ -713,7 +713,7 @@ fn resolving_with_deep_backtracking() {
|
||||
pkg!(("dep_req", "2.0.0")),
|
||||
]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap();
|
||||
|
||||
assert_same(
|
||||
&res,
|
||||
@ -741,7 +741,7 @@ fn resolving_with_sys_crates() {
|
||||
]);
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req("d", "1"), dep_req("r", "1")],
|
||||
®,
|
||||
)
|
||||
@ -794,7 +794,7 @@ fn resolving_with_constrained_sibling_backtrack_parent() {
|
||||
}
|
||||
let reg = registry(reglist);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap();
|
||||
|
||||
assert_contains(
|
||||
&res,
|
||||
@ -829,7 +829,7 @@ fn resolving_with_many_equivalent_backtracking() {
|
||||
|
||||
let reg = registry(reglist.clone());
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep("level0")], ®);
|
||||
let res = resolve(pkg_id("root"), vec![dep("level0")], ®);
|
||||
|
||||
assert!(res.is_err());
|
||||
|
||||
@ -839,7 +839,7 @@ fn resolving_with_many_equivalent_backtracking() {
|
||||
|
||||
let reg = registry(reglist.clone());
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep("level0")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("level0")], ®).unwrap();
|
||||
|
||||
assert_contains(&res, &names(&[("root", "1.0.0"), ("level0", "1.0.0")]));
|
||||
|
||||
@ -853,7 +853,7 @@ fn resolving_with_many_equivalent_backtracking() {
|
||||
let reg = registry(reglist.clone());
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep("level0"), dep("constrained")],
|
||||
®,
|
||||
)
|
||||
@ -871,7 +871,7 @@ fn resolving_with_many_equivalent_backtracking() {
|
||||
let reg = registry(reglist.clone());
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req("level0", "1.0.1"), dep("constrained")],
|
||||
®,
|
||||
)
|
||||
@ -889,7 +889,7 @@ fn resolving_with_many_equivalent_backtracking() {
|
||||
let reg = registry(reglist.clone());
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req("level0", "1.0.1"), dep_req("constrained", "1.1.0")],
|
||||
®,
|
||||
);
|
||||
@ -932,7 +932,7 @@ fn resolving_with_deep_traps() {
|
||||
let reg = registry(reglist.clone());
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep("backtrack_trap0"), dep("cloaking")],
|
||||
®,
|
||||
);
|
||||
@ -984,7 +984,7 @@ fn resolving_with_constrained_cousins_backtrack() {
|
||||
// but `constrained= "2.0.1"` is already picked.
|
||||
// Only then to try and solve `constrained= "~1.0.0"` which is incompatible.
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![
|
||||
dep("backtrack_trap0"),
|
||||
dep_req("constrained", "2.0.1"),
|
||||
@ -1014,7 +1014,7 @@ fn resolving_with_constrained_cousins_backtrack() {
|
||||
let reg = registry(reglist.clone());
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep("level0"), dep_req("constrained", "2.0.1")],
|
||||
®,
|
||||
);
|
||||
@ -1022,7 +1022,7 @@ fn resolving_with_constrained_cousins_backtrack() {
|
||||
assert!(res.is_err());
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep("level0"), dep_req("constrained", "2.0.0")],
|
||||
®,
|
||||
)
|
||||
@ -1066,7 +1066,7 @@ fn resolving_with_constrained_sibling_backtrack_activation() {
|
||||
}
|
||||
let reg = registry(reglist);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("foo", "1")], ®).unwrap();
|
||||
|
||||
assert_contains(
|
||||
&res,
|
||||
@ -1112,7 +1112,7 @@ fn resolving_with_constrained_sibling_transitive_dep_effects() {
|
||||
pkg!(("D", "1.0.105")),
|
||||
]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("A", "1")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("A", "1")], ®).unwrap();
|
||||
|
||||
assert_same(
|
||||
&res,
|
||||
@ -1158,7 +1158,7 @@ fn incomplete_information_skiping() {
|
||||
];
|
||||
let reg = registry(input.clone());
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep("g")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("g")], ®).unwrap();
|
||||
let package_to_yank = "to_yank".to_pkgid();
|
||||
// this package is not used in the resolution.
|
||||
assert!(!res.contains(&package_to_yank));
|
||||
@ -1172,7 +1172,7 @@ fn incomplete_information_skiping() {
|
||||
);
|
||||
assert_eq!(input.len(), new_reg.len() + 1);
|
||||
// it should still build
|
||||
assert!(resolve(&pkg_id("root"), vec![dep("g")], &new_reg).is_ok());
|
||||
assert!(resolve(pkg_id("root"), vec![dep("g")], &new_reg).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1227,7 +1227,7 @@ fn incomplete_information_skiping_2() {
|
||||
];
|
||||
let reg = registry(input.clone());
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep("i")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("i")], ®).unwrap();
|
||||
let package_to_yank = ("to_yank", "8.8.1").to_pkgid();
|
||||
// this package is not used in the resolution.
|
||||
assert!(!res.contains(&package_to_yank));
|
||||
@ -1241,7 +1241,7 @@ fn incomplete_information_skiping_2() {
|
||||
);
|
||||
assert_eq!(input.len(), new_reg.len() + 1);
|
||||
// it should still build
|
||||
assert!(resolve(&pkg_id("root"), vec![dep("i")], &new_reg).is_ok());
|
||||
assert!(resolve(pkg_id("root"), vec![dep("i")], &new_reg).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1277,7 +1277,7 @@ fn incomplete_information_skiping_3() {
|
||||
];
|
||||
let reg = registry(input.clone());
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep("b")], ®).unwrap();
|
||||
let res = resolve(pkg_id("root"), vec![dep("b")], ®).unwrap();
|
||||
let package_to_yank = ("to_yank", "3.0.3").to_pkgid();
|
||||
// this package is not used in the resolution.
|
||||
assert!(!res.contains(&package_to_yank));
|
||||
@ -1291,14 +1291,14 @@ fn incomplete_information_skiping_3() {
|
||||
);
|
||||
assert_eq!(input.len(), new_reg.len() + 1);
|
||||
// it should still build
|
||||
assert!(resolve(&pkg_id("root"), vec![dep("b")], &new_reg).is_ok());
|
||||
assert!(resolve(pkg_id("root"), vec![dep("b")], &new_reg).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolving_but_no_exists() {
|
||||
let reg = registry(vec![]);
|
||||
|
||||
let res = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®);
|
||||
let res = resolve(pkg_id("root"), vec![dep_req("foo", "1")], ®);
|
||||
assert!(res.is_err());
|
||||
|
||||
assert_eq!(
|
||||
@ -1315,7 +1315,7 @@ fn resolving_but_no_exists() {
|
||||
fn resolving_cycle() {
|
||||
let reg = registry(vec![pkg!("foo" => ["foo"])]);
|
||||
|
||||
let _ = resolve(&pkg_id("root"), vec![dep_req("foo", "1")], ®);
|
||||
let _ = resolve(pkg_id("root"), vec![dep_req("foo", "1")], ®);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1327,7 +1327,7 @@ fn hard_equality() {
|
||||
]);
|
||||
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req("bar", "1"), dep_req("foo", "=1.0.0")],
|
||||
®,
|
||||
)
|
||||
@ -1365,7 +1365,7 @@ fn large_conflict_cache() {
|
||||
}
|
||||
}
|
||||
let reg = registry(input);
|
||||
let _ = resolve(&pkg_id("root"), root_deps, ®);
|
||||
let _ = resolve(pkg_id("root"), root_deps, ®);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@ -1405,5 +1405,5 @@ fn conflict_store_bug() {
|
||||
];
|
||||
|
||||
let reg = registry(input.clone());
|
||||
let _ = resolve_and_validated(&pkg_id("root"), vec![dep("j")], ®);
|
||||
let _ = resolve_and_validated(pkg_id("root"), vec![dep("j")], ®);
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ pub fn main_file(println: &str, deps: &[&str]) -> String {
|
||||
}
|
||||
|
||||
buf.push_str("fn main() { println!(");
|
||||
buf.push_str(&println);
|
||||
buf.push_str(println);
|
||||
buf.push_str("); }\n");
|
||||
|
||||
buf.to_string()
|
||||
@ -926,7 +926,7 @@ impl Execs {
|
||||
}
|
||||
for &(ref expect, number) in self.expect_stdout_contains_n.iter() {
|
||||
self.match_std(
|
||||
Some(&expect),
|
||||
Some(expect),
|
||||
&actual.stdout,
|
||||
"stdout",
|
||||
&actual.stderr,
|
||||
@ -1246,7 +1246,7 @@ impl Execs {
|
||||
.enumerate()
|
||||
.filter_map(|(i, (a, e))| match (a, e) {
|
||||
(Some(a), Some(e)) => {
|
||||
if lines_match(&e, &a) {
|
||||
if lines_match(e, a) {
|
||||
None
|
||||
} else {
|
||||
Some(format!("{:3} - |{}|\n + |{}|\n", i, e, a))
|
||||
@ -1327,7 +1327,7 @@ fn lines_match_works() {
|
||||
/// arbitrary nested JSON (useful for parts of object emitted by other programs
|
||||
/// (e.g., rustc) rather than Cargo itself). Arrays are sorted before comparison.
|
||||
pub fn find_json_mismatch(expected: &Value, actual: &Value) -> Result<(), String> {
|
||||
match find_json_mismatch_r(expected, &actual) {
|
||||
match find_json_mismatch_r(expected, actual) {
|
||||
Some((expected_part, actual_part)) => Err(format!(
|
||||
"JSON mismatch\nExpected:\n{}\nWas:\n{}\nExpected part:\n{}\nActual part:\n{}\n",
|
||||
serde_json::to_string_pretty(expected).unwrap(),
|
||||
@ -1368,7 +1368,7 @@ fn find_json_mismatch_r<'a>(
|
||||
|
||||
if !l.is_empty() {
|
||||
assert!(!r.is_empty());
|
||||
Some((&l[0], &r[0]))
|
||||
Some((l[0], r[0]))
|
||||
} else {
|
||||
assert_eq!(r.len(), 0);
|
||||
None
|
||||
|
@ -21,7 +21,7 @@ use proptest::string::string_regex;
|
||||
use proptest::test_runner::TestRunner;
|
||||
|
||||
pub fn resolve(
|
||||
pkg: &PackageId,
|
||||
pkg: PackageId,
|
||||
deps: Vec<Dependency>,
|
||||
registry: &[Summary],
|
||||
) -> CargoResult<Vec<PackageId>> {
|
||||
@ -29,7 +29,7 @@ pub fn resolve(
|
||||
}
|
||||
|
||||
pub fn resolve_and_validated(
|
||||
pkg: &PackageId,
|
||||
pkg: PackageId,
|
||||
deps: Vec<Dependency>,
|
||||
registry: &[Summary],
|
||||
) -> CargoResult<Vec<PackageId>> {
|
||||
@ -58,7 +58,7 @@ pub fn resolve_and_validated(
|
||||
}
|
||||
|
||||
pub fn resolve_with_config(
|
||||
pkg: &PackageId,
|
||||
pkg: PackageId,
|
||||
deps: Vec<Dependency>,
|
||||
registry: &[Summary],
|
||||
config: Option<&Config>,
|
||||
@ -68,7 +68,7 @@ pub fn resolve_with_config(
|
||||
}
|
||||
|
||||
pub fn resolve_with_config_raw(
|
||||
pkg: &PackageId,
|
||||
pkg: PackageId,
|
||||
deps: Vec<Dependency>,
|
||||
registry: &[Summary],
|
||||
config: Option<&Config>,
|
||||
@ -461,7 +461,7 @@ pub fn registry_strategy(
|
||||
let (c, d) = order_index(c, d, s.len());
|
||||
|
||||
dependency_by_pkgid[b].push(dep_req_kind(
|
||||
&dep_name,
|
||||
dep_name,
|
||||
&if c == 0 && d == s_last_index {
|
||||
"*".to_string()
|
||||
} else if c == 0 {
|
||||
@ -525,7 +525,7 @@ fn meta_test_deep_trees_from_strategy() {
|
||||
let reg = registry(input.clone());
|
||||
for this in input.iter().rev().take(10) {
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
®,
|
||||
);
|
||||
@ -564,7 +564,7 @@ fn meta_test_multiple_versions_strategy() {
|
||||
let reg = registry(input.clone());
|
||||
for this in input.iter().rev().take(10) {
|
||||
let res = resolve(
|
||||
&pkg_id("root"),
|
||||
pkg_id("root"),
|
||||
vec![dep_req(&this.name(), &format!("={}", this.version()))],
|
||||
®,
|
||||
);
|
||||
|
Loading…
x
Reference in New Issue
Block a user