diff --git a/src/processor/checker.rs b/src/processor/checker.rs index cf10600..4e8e8bc 100644 --- a/src/processor/checker.rs +++ b/src/processor/checker.rs @@ -1,8 +1,21 @@ -use std::{collections::BTreeSet, mem}; +use std::{borrow::Borrow, collections::BTreeSet, fmt::Debug, mem}; use self::worklist::Worklist; -use super::AstPath; +#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] +struct AstPath(Vec); + +impl Borrow<[String]> for AstPath { + fn borrow(&self) -> &[String] { + &self.0 + } +} + +impl Debug for AstPath { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + write!(f, "AstPath({:?})", self.0) + } +} #[derive(Debug)] pub(crate) struct PassController { @@ -96,7 +109,7 @@ impl PassController { self.next_in_worklist(); } - PassControllerState::Success => unreachable!("Processed after success"), + PassControllerState::Success { .. } => unreachable!("Processed after success"), } } @@ -116,11 +129,19 @@ impl PassController { }; } PassControllerState::Bisecting { - committed: _, + committed, failed, current, worklist, } => { + debug!( + ?committed, + ?failed, + ?current, + ?worklist, + "Does not reproduce" + ); + if current.len() == 1 { // We are at a leaf. This is a failure. // FIXME: We should retry the failed ones until a fixpoint is reached. @@ -135,7 +156,7 @@ impl PassController { self.next_in_worklist() } - PassControllerState::Success => unreachable!("Processed after success"), + PassControllerState::Success { .. } => unreachable!("Processed after success"), } } @@ -151,7 +172,7 @@ impl PassController { PassControllerState::Bisecting { current, .. } => { unreachable!("No change while bisecting, current was empty somehow: {current:?}"); } - PassControllerState::Success => {} + PassControllerState::Success { .. } => {} } } @@ -159,7 +180,7 @@ impl PassController { match &mut self.state { PassControllerState::InitialCollection { .. } => false, PassControllerState::Bisecting { .. } => false, - PassControllerState::Success => true, + PassControllerState::Success { .. } => true, } } @@ -170,7 +191,7 @@ impl PassController { true } PassControllerState::Bisecting { current, .. } => current.contains(path), - PassControllerState::Success => { + PassControllerState::Success { .. } => { unreachable!("Processed further after success"); } } diff --git a/src/processor/mod.rs b/src/processor/mod.rs index 2cb6ce0..e73d6ee 100644 --- a/src/processor/mod.rs +++ b/src/processor/mod.rs @@ -6,7 +6,7 @@ pub(crate) use self::files::SourceFile; use crate::{build::Build, processor::files::Changes, Options}; use anyhow::{Context, Result}; use owo_colors::OwoColorize; -use std::{borrow::Borrow, collections::HashSet, ffi::OsStr, fmt::Debug}; +use std::{collections::HashSet, ffi::OsStr, fmt::Debug}; pub(crate) use self::checker::PassController; @@ -144,9 +144,12 @@ impl Minimizer { match has_made_change { ProcessState::Changed | ProcessState::FileInvalidated => { let result = prettyplease::unparse(&krate); + change.write(&result)?; + let after = self.build.build()?; info!("{file_display}: After {}: {after}", pass.name()); + if after.reproduces_issue() { change.commit(); checker.reproduces(); @@ -154,6 +157,7 @@ impl Minimizer { change.rollback()?; checker.does_not_reproduce(); } + if has_made_change == ProcessState::FileInvalidated { invalidated_files.insert(file); } @@ -180,21 +184,6 @@ impl Minimizer { } } -#[derive(Clone, PartialEq, Eq, Hash, PartialOrd, Ord)] -struct AstPath(Vec); - -impl Borrow<[String]> for AstPath { - fn borrow(&self) -> &[String] { - &self.0 - } -} - -impl Debug for AstPath { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "AstPath({:?})", self.0) - } -} - macro_rules! tracking { () => { tracking!(visit_item_fn_mut);