Skip to content

Commit

Permalink
Unify no-library-target error into no-target warn
Browse files Browse the repository at this point in the history
(This is a stripped cherry-pick friendly version of the original pr:
rust-lang#14163)
  • Loading branch information
ryoqun committed Jun 28, 2024
1 parent 6087566 commit fe265c7
Showing 1 changed file with 12 additions and 24 deletions.
36 changes: 12 additions & 24 deletions src/cargo/ops/cargo_compile/unit_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@ impl<'a> UnitGenerator<'a, '_> {
}
}
CompileFilter::Only {
all_targets,
all_targets: _,
ref lib,
ref bins,
ref examples,
Expand All @@ -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::<Vec<_>>();
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);
}

Expand Down Expand Up @@ -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,
Expand All @@ -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`,");
Expand Down

0 comments on commit fe265c7

Please sign in to comment.