@@ -199,14 +199,14 @@ fn classify_use(tree: &UseTree, manifest: &Manifest) -> UseShape {
199199 let mut full = prefix. clone ( ) ;
200200 full. push ( name. clone ( ) ) ;
201201 let path = full. join ( "::" ) ;
202- let Some ( feature) = manifest. paths . get ( & path) else {
202+ let Some ( ( full_path , feature) ) = manifest. resolve_path ( & path) else {
203203 return UseShape :: Other ;
204204 } ;
205205 return UseShape :: Single {
206206 leaf : EngageLeaf {
207- full_path : path ,
207+ full_path : full_path . to_string ( ) ,
208208 local_name : name,
209- feature : feature. clone ( ) ,
209+ feature : feature. to_string ( ) ,
210210 } ,
211211 } ;
212212 }
@@ -216,14 +216,14 @@ fn classify_use(tree: &UseTree, manifest: &Manifest) -> UseShape {
216216 let mut full = prefix. clone ( ) ;
217217 full. push ( name. clone ( ) ) ;
218218 let path = full. join ( "::" ) ;
219- let Some ( feature) = manifest. paths . get ( & path) else {
219+ let Some ( ( full_path , feature) ) = manifest. resolve_path ( & path) else {
220220 return UseShape :: Other ;
221221 } ;
222222 return UseShape :: Single {
223223 leaf : EngageLeaf {
224- full_path : path ,
224+ full_path : full_path . to_string ( ) ,
225225 local_name : local,
226- feature : feature. clone ( ) ,
226+ feature : feature. to_string ( ) ,
227227 } ,
228228 } ;
229229 }
@@ -236,12 +236,12 @@ fn classify_use(tree: &UseTree, manifest: &Manifest) -> UseShape {
236236 let mut full = prefix. clone ( ) ;
237237 full. push ( name. clone ( ) ) ;
238238 let path = full. join ( "::" ) ;
239- let kind = if let Some ( feature) = manifest. paths . get ( & path) {
239+ let kind = if let Some ( ( full_path , feature) ) = manifest. resolve_path ( & path) {
240240 MemberKind :: Engage {
241241 leaf : EngageLeaf {
242- full_path : path ,
242+ full_path : full_path . to_string ( ) ,
243243 local_name : name. clone ( ) ,
244- feature : feature. clone ( ) ,
244+ feature : feature. to_string ( ) ,
245245 } ,
246246 }
247247 } else {
@@ -258,12 +258,12 @@ fn classify_use(tree: &UseTree, manifest: &Manifest) -> UseShape {
258258 let mut full = prefix. clone ( ) ;
259259 full. push ( name. clone ( ) ) ;
260260 let path = full. join ( "::" ) ;
261- let kind = if let Some ( feature) = manifest. paths . get ( & path) {
261+ let kind = if let Some ( ( full_path , feature) ) = manifest. resolve_path ( & path) {
262262 MemberKind :: Engage {
263263 leaf : EngageLeaf {
264- full_path : path ,
264+ full_path : full_path . to_string ( ) ,
265265 local_name : local. clone ( ) ,
266- feature : feature. clone ( ) ,
266+ feature : feature. to_string ( ) ,
267267 } ,
268268 }
269269 } else {
@@ -336,6 +336,27 @@ impl<'ast> Visit<'ast> for BodyRefVisitor {
336336 fn visit_ident ( & mut self , ident : & ' ast proc_macro2:: Ident ) {
337337 self . out . insert ( strip_raw ( & ident. to_string ( ) ) ) ;
338338 }
339+
340+ // syn keeps a macro's contents as raw tokens and never parses them, so a type
341+ // used only inside something like `vec![Fade::black_out(...)]` is invisible to
342+ // the normal walk. Pull every identifier out of the macro tokens so we don't
343+ // call a still-used import dead and delete it.
344+ fn visit_macro ( & mut self , mac : & ' ast syn:: Macro ) {
345+ collect_idents_from_tokens ( mac. tokens . clone ( ) , & mut self . out ) ;
346+ syn:: visit:: visit_macro ( self , mac) ;
347+ }
348+ }
349+
350+ fn collect_idents_from_tokens ( tokens : proc_macro2:: TokenStream , out : & mut BTreeSet < String > ) {
351+ for tt in tokens {
352+ match tt {
353+ proc_macro2:: TokenTree :: Ident ( id) => {
354+ out. insert ( strip_raw ( & id. to_string ( ) ) ) ;
355+ }
356+ proc_macro2:: TokenTree :: Group ( g) => collect_idents_from_tokens ( g. stream ( ) , out) ,
357+ _ => { }
358+ }
359+ }
339360}
340361
341362pub fn apply_use_edits ( file : & Path , edits : & [ UseEdit ] ) -> Result < ( ) > {
0 commit comments