Skip to content

Commit 33718c7

Browse files
committed
Fix repeated warning with two calls to to_package_id_specs
1 parent 0a2382b commit 33718c7

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/cargo/ops/cargo_compile.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -369,20 +369,19 @@ pub fn create_bcx<'a, 'cfg>(
369369
let target_data = RustcTargetData::new(ws, &build_config.requested_kinds)?;
370370

371371
let all_packages = &Packages::All;
372-
let full_specs = if rustdoc_scrape_examples.is_some() {
372+
let need_reverse_dependencies = rustdoc_scrape_examples.is_some();
373+
let full_specs = if need_reverse_dependencies {
373374
all_packages
374375
} else {
375376
spec
376377
};
377378

378-
let specs = spec.to_package_id_specs(ws)?;
379379
let resolve_specs = full_specs.to_package_id_specs(ws)?;
380-
let has_dev_units =
381-
if filter.need_dev_deps(build_config.mode) || rustdoc_scrape_examples.is_some() {
382-
HasDevUnits::Yes
383-
} else {
384-
HasDevUnits::No
385-
};
380+
let has_dev_units = if filter.need_dev_deps(build_config.mode) || need_reverse_dependencies {
381+
HasDevUnits::Yes
382+
} else {
383+
HasDevUnits::No
384+
};
386385
let resolve = ops::resolve_ws_with_opts(
387386
ws,
388387
&target_data,
@@ -422,6 +421,11 @@ pub fn create_bcx<'a, 'cfg>(
422421
// Find the packages in the resolver that the user wants to build (those
423422
// passed in with `-p` or the defaults from the workspace), and convert
424423
// Vec<PackageIdSpec> to a Vec<PackageId>.
424+
let specs = if need_reverse_dependencies {
425+
spec.to_package_id_specs(ws)?
426+
} else {
427+
resolve_specs.clone()
428+
};
425429
let to_build_ids = resolve.specs_to_ids(&specs)?;
426430
// Now get the `Package` for each `PackageId`. This may trigger a download
427431
// if the user specified `-p` for a dependency that is not downloaded.

0 commit comments

Comments
 (0)