mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-17 01:35:01 +01:00
run_pass fn
This commit is contained in:
parent
ed8da36a92
commit
865d8a7bc9
2 changed files with 63 additions and 57 deletions
|
|
@ -76,9 +76,16 @@ impl Minimizer {
|
|||
"Initial build must reproduce issue"
|
||||
);
|
||||
|
||||
for mut pass in passes {
|
||||
self.run_pass(&mut *pass)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn run_pass(&mut self, pass: &mut dyn Processor) -> Result<()> {
|
||||
let mut invalidated_files = HashSet::new();
|
||||
|
||||
for mut pass in passes {
|
||||
let mut refresh_and_try_again = false;
|
||||
|
||||
'pass: loop {
|
||||
|
|
@ -97,8 +104,7 @@ impl Minimizer {
|
|||
let mut krate = syn::parse_file(change.before_content())
|
||||
.with_context(|| format!("parsing file {file_display}"))?;
|
||||
|
||||
let has_made_change =
|
||||
pass.process_file(&mut krate, file, &mut ProcessChecker {});
|
||||
let has_made_change = pass.process_file(&mut krate, file, &mut ProcessChecker {});
|
||||
|
||||
match has_made_change {
|
||||
ProcessState::Changed | ProcessState::FileInvalidated => {
|
||||
|
|
@ -130,6 +136,7 @@ impl Minimizer {
|
|||
if !refresh_and_try_again && invalidated_files.len() > 0 {
|
||||
// A few files have been invalidated, let's refresh and try these again.
|
||||
pass.refresh_state().context("refreshing state for pass")?;
|
||||
invalidated_files.clear();
|
||||
refresh_and_try_again = true;
|
||||
println!("Refreshing files for {}", pass.name());
|
||||
continue;
|
||||
|
|
@ -141,7 +148,6 @@ impl Minimizer {
|
|||
refresh_and_try_again = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -112,7 +112,7 @@ impl Processor for DeleteUnusedFunctions {
|
|||
fn refresh_state(&mut self) -> Result<()> {
|
||||
let (diags, _) = self.build.get_diags().context("getting diagnostics")?;
|
||||
self.diags = diags;
|
||||
self.invalid = HashSet::new();
|
||||
self.invalid.clear();
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue