mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-14 16:35:01 +01:00
Cleanup
This commit is contained in:
parent
a50131cf64
commit
a1efa3fd56
2 changed files with 34 additions and 24 deletions
|
|
@ -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<String>);
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String>);
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue