diff --git a/src/cargo/ops/cargo_compile/unit_generator.rs b/src/cargo/ops/cargo_compile/unit_generator.rs index b2d86b7531c..0816b8f14aa 100644 --- a/src/cargo/ops/cargo_compile/unit_generator.rs +++ b/src/cargo/ops/cargo_compile/unit_generator.rs @@ -349,7 +349,7 @@ impl<'a> UnitGenerator<'a, '_> { } } CompileFilter::Only { - all_targets, + all_targets: _, ref lib, ref bins, ref examples, @@ -372,21 +372,6 @@ impl<'a> UnitGenerator<'a, '_> { libs.push(proposal) } } - if !all_targets && libs.is_empty() && *lib == LibRule::True { - let names = self - .packages - .iter() - .map(|pkg| pkg.name()) - .collect::>(); - if names.len() == 1 { - anyhow::bail!("no library targets found in package `{}`", names[0]); - } else { - anyhow::bail!( - "no library targets found in packages: {}", - names.join(", ") - ); - } - } proposals.extend(libs); } @@ -510,7 +495,7 @@ Rustdoc did not scrape the following examples because they require dev-dependenc let mut shell = self.ws.gctx().shell(); if let CompileFilter::Only { all_targets, - lib: _, + ref lib, ref bins, ref examples, ref tests, @@ -521,16 +506,19 @@ Rustdoc did not scrape the following examples because they require dev-dependenc let mut filters = String::new(); let mut miss_count = 0; - let mut append = |t: &FilterRule, s| { - if let FilterRule::All = *t { - miss_count += 1; - filters.push_str(s); - } - }; - if all_targets { filters.push_str(" `all-targets`"); } else { + if *lib == LibRule::True { + miss_count += 1; + filters.push_str(" `lib`,"); + } + let mut append = |t: &FilterRule, s| { + if let FilterRule::All = *t { + miss_count += 1; + filters.push_str(s); + } + }; append(bins, " `bins`,"); append(tests, " `tests`,"); append(examples, " `examples`,");