mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-15 00:45:02 +01:00
item deleter pass
This commit is contained in:
parent
22804c3065
commit
fdfde615f6
8 changed files with 162 additions and 5 deletions
|
|
@ -56,6 +56,15 @@ pub(crate) struct Minimizer {
|
|||
}
|
||||
|
||||
impl Minimizer {
|
||||
fn pass_disabled(&self, name: &str) -> bool {
|
||||
if let Some(passes) = &self.options.passes {
|
||||
if !passes.split(",").any(|allowed| name == allowed) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
pub(crate) fn new_glob_dir(options: Options, build: Build) -> Result<Self> {
|
||||
let path = &options.path;
|
||||
let walk = walkdir::WalkDir::new(path);
|
||||
|
|
@ -102,6 +111,9 @@ impl Minimizer {
|
|||
inital_build.require_reproduction("Initial")?;
|
||||
|
||||
for mut pass in passes {
|
||||
if self.pass_disabled(pass.name()) {
|
||||
continue;
|
||||
}
|
||||
self.run_pass(&mut *pass)?;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,8 +18,14 @@ fn file_for_suggestion(suggestion: &Suggestion) -> &str {
|
|||
&suggestion.solutions[0].replacements[0].snippet.file_name
|
||||
}
|
||||
|
||||
const PASS_NAME: &str = "delete-unused-functions";
|
||||
|
||||
impl Minimizer {
|
||||
pub fn delete_dead_code(&mut self) -> Result<()> {
|
||||
if self.pass_disabled(PASS_NAME) {
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
let inital_build = self.build.build()?;
|
||||
info!("Before reaper: {inital_build}");
|
||||
|
||||
|
|
@ -139,7 +145,7 @@ impl Pass for DeleteUnusedFunctions {
|
|||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
"delete-unused-functions"
|
||||
PASS_NAME
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue