mirror of
https://github.com/Noratrieb/cargo-minimize.git
synced 2026-01-14 08:25:01 +01:00
Teach item-deleter to delete imports.
Because reaper is finnicky and does not always work for whatever reason. The new test from a couple commits ago now passes.
This commit is contained in:
parent
3de6992d63
commit
a87558adf7
1 changed files with 12 additions and 3 deletions
|
|
@ -1,7 +1,8 @@
|
|||
use quote::ToTokens;
|
||||
use syn::{
|
||||
visit_mut::VisitMut, Item, ItemConst, ItemEnum, ItemExternCrate, ItemFn, ItemMacro, ItemMacro2,
|
||||
ItemMod, ItemStatic, ItemStruct, ItemTrait, ItemTraitAlias, ItemType, ItemUnion, Signature,
|
||||
ItemMod, ItemStatic, ItemStruct, ItemTrait, ItemTraitAlias, ItemType, ItemUnion, ItemUse,
|
||||
Signature,
|
||||
};
|
||||
|
||||
use crate::processor::{tracking, Pass, PassController, ProcessState, SourceFile};
|
||||
|
|
@ -73,9 +74,17 @@ impl<'a> Visitor<'a> {
|
|||
self.current_path.pop();
|
||||
should_retain
|
||||
}
|
||||
// We would hope for the unused imports pass to catch all of these
|
||||
// but sadly that's not the case
|
||||
Item::Use(ItemUse { tree, .. }) => {
|
||||
self.current_path.push(tree.to_token_stream().to_string());
|
||||
|
||||
let should_retain = self.should_retain_item();
|
||||
|
||||
self.current_path.pop();
|
||||
should_retain
|
||||
}
|
||||
Item::ForeignMod(_) => true,
|
||||
// We hope for the unused imports to show them all.
|
||||
Item::Use(_) => true,
|
||||
Item::Verbatim(_) => true,
|
||||
_ => true,
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue