Skip to content

Commit

Permalink
Add --keep-going option
Browse files Browse the repository at this point in the history
  • Loading branch information
smoelius committed Nov 5, 2021
1 parent 28f3691 commit bbf0a3c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
5 changes: 5 additions & 0 deletions cargo-dylint/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ pub struct Dylint {
#[clap(long, hidden = true)]
pub isolate: bool,

#[clap(long, about = "Continue if `cargo check` fails")]
pub keep_going: bool,

#[clap(
multiple_occurrences = true,
number_of_values = 1,
Expand Down Expand Up @@ -146,6 +149,7 @@ impl From<Dylint> for dylint::Dylint {
let Dylint {
all,
isolate,
keep_going,
libs,
list,
manifest_path,
Expand All @@ -164,6 +168,7 @@ impl From<Dylint> for dylint::Dylint {
Self {
all,
isolate,
keep_going,
libs,
list,
manifest_path,
Expand Down
23 changes: 20 additions & 3 deletions dylint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ pub type NameToolchainMap = BTreeMap<String, ToolchainMap>;
pub struct Dylint {
pub all: bool,
pub isolate: bool,
pub keep_going: bool,
pub libs: Vec<String>,
pub list: bool,
pub manifest_path: Option<String>,
Expand Down Expand Up @@ -428,6 +429,8 @@ fn check(
) -> Result<()> {
let clippy_disable_docs_links = clippy_disable_docs_links()?;

let mut failures = Vec::new();

for (toolchain, paths) in resolved {
let target_dir = target_dir(opts, toolchain)?;
let target_dir_str = target_dir.to_string_lossy();
Expand All @@ -453,7 +456,7 @@ fn check(
// https://github.com/rust-lang/rust-clippy/commit/1a206fc4abae0b57a3f393481367cf3efca23586
// But I am going to continue to set CLIPPY_DISABLE_DOCS_LINKS because it doesn't seem to
// hurt and it provides a small amount of backward compatibility.
dylint_internal::check()
let result = dylint_internal::check()
.envs(vec![
(
env::CLIPPY_DISABLE_DOCS_LINKS.to_owned(),
Expand All @@ -467,10 +470,24 @@ fn check(
(env::RUSTUP_TOOLCHAIN.to_owned(), toolchain.clone()),
])
.args(args)
.success()?;
.success();
if result.is_err() {
if !opts.keep_going {
return result
.with_context(|| format!("Compilation failed with toolchain `{}`", toolchain));
};
failures.push(toolchain);
}
}

Ok(())
if failures.is_empty() {
Ok(())
} else {
Err(anyhow!(
"Compilation failed with the following toolchains: {:?}",
failures
))
}
}

fn target_dir(opts: &Dylint, toolchain: &str) -> Result<PathBuf> {
Expand Down

0 comments on commit bbf0a3c

Please sign in to comment.