Skip to content

Commit

Permalink
Only emit unused warnings if we ran cargo clean when we started
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlattimore committed Sep 20, 2023
1 parent cdc2ede commit 802ac30
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ impl Cackle {
return Ok(outcome::FAILURE);
}
{
let should_run_cargo_clean = self.should_run_cargo_clean();
let checker = &mut self.checker.lock().unwrap();
checker.load_config()?;

if !self.args.replay_requests && !matches!(self.args.command, Some(Command::Cargo(..)))
{
if should_run_cargo_clean {
proxy::clean(&self.root_path, &self.args, &checker.config.raw.common)?;
}
}
Expand Down Expand Up @@ -394,15 +394,23 @@ impl Cackle {
// We only check if the build failed if there were no ACL check errors.
build_result?;

let unused_problems = self.checker.lock().unwrap().check_unused()?;
let resolution = self.problem_store.fix_problems(unused_problems);
if resolution != Outcome::Continue {
return Ok(outcome::FAILURE);
// If we didn't run `cargo clean` when we started, then our records of what is an isn't used
// won't be complete, so we shouldn't emit unused warnings.
if self.should_run_cargo_clean() {
let unused_problems = self.checker.lock().unwrap().check_unused()?;
let resolution = self.problem_store.fix_problems(unused_problems);
if resolution != Outcome::Continue {
return Ok(outcome::FAILURE);
}
}

Ok(outcome::SUCCESS)
}

fn should_run_cargo_clean(&mut self) -> bool {
!self.args.replay_requests && !matches!(self.args.command, Some(Command::Cargo(..)))
}

fn new_request_handler(&self, request: Option<Request>) -> RequestHandler {
RequestHandler {
check_state: CheckState::default(),
Expand Down

0 comments on commit 802ac30

Please sign in to comment.