@@ -395,9 +395,8 @@ impl DefCollector<'_> {
395
395
// As some of the macros will expand newly import shadowing partial resolved imports
396
396
// FIXME: We maybe could skip this, if we handle the indeterminate imports in `resolve_imports`
397
397
// correctly
398
- let partial_resolved = self . indeterminate_imports . drain ( ..) . filter_map ( |mut directive| {
399
- directive. status = PartialResolvedImport :: Unresolved ;
400
- Some ( directive)
398
+ let partial_resolved = self . indeterminate_imports . drain ( ..) . map ( |directive| {
399
+ ImportDirective { status : PartialResolvedImport :: Unresolved , ..directive }
401
400
} ) ;
402
401
self . unresolved_imports . extend ( partial_resolved) ;
403
402
self . resolve_imports ( ) ;
@@ -434,50 +433,48 @@ impl DefCollector<'_> {
434
433
fn reseed_with_unresolved_attribute ( & mut self ) -> ReachedFixedPoint {
435
434
cov_mark:: hit!( unresolved_attribute_fallback) ;
436
435
437
- let mut unresolved_macros = mem:: take ( & mut self . unresolved_macros ) ;
438
- let pos = unresolved_macros. iter ( ) . position ( |directive| {
439
- if let MacroDirectiveKind :: Attr { ast_id, mod_item, attr, tree } = & directive. kind {
440
- self . def_map . diagnostics . push ( DefDiagnostic :: unresolved_macro_call (
441
- directive. module_id ,
442
- MacroCallKind :: Attr {
443
- ast_id : ast_id. ast_id ,
444
- attr_args : Default :: default ( ) ,
445
- invoc_attr_index : attr. id . ast_index ,
446
- is_derive : false ,
447
- } ,
448
- attr. path ( ) . clone ( ) ,
449
- ) ) ;
436
+ let unresolved_attr =
437
+ self . unresolved_macros . iter ( ) . enumerate ( ) . find_map ( |( idx, directive) | match & directive
438
+ . kind
439
+ {
440
+ MacroDirectiveKind :: Attr { ast_id, mod_item, attr, tree } => {
441
+ self . def_map . diagnostics . push ( DefDiagnostic :: unresolved_macro_call (
442
+ directive. module_id ,
443
+ MacroCallKind :: Attr {
444
+ ast_id : ast_id. ast_id ,
445
+ attr_args : Default :: default ( ) ,
446
+ invoc_attr_index : attr. id . ast_index ,
447
+ is_derive : false ,
448
+ } ,
449
+ attr. path ( ) . clone ( ) ,
450
+ ) ) ;
450
451
451
- self . skip_attrs . insert ( ast_id. ast_id . with_value ( * mod_item) , attr. id ) ;
452
+ self . skip_attrs . insert ( ast_id. ast_id . with_value ( * mod_item) , attr. id ) ;
452
453
453
- let item_tree = tree. item_tree ( self . db ) ;
454
- let mod_dir = self . mod_dirs [ & directive. module_id ] . clone ( ) ;
454
+ Some ( ( idx, directive, * mod_item, * tree) )
455
+ }
456
+ _ => None ,
457
+ } ) ;
458
+
459
+ match unresolved_attr {
460
+ Some ( ( pos, & MacroDirective { module_id, depth, container, .. } , mod_item, tree_id) ) => {
461
+ let item_tree = & tree_id. item_tree ( self . db ) ;
462
+ let mod_dir = self . mod_dirs [ & module_id] . clone ( ) ;
455
463
ModCollector {
456
464
def_collector : self ,
457
- macro_depth : directive . depth ,
458
- module_id : directive . module_id ,
459
- tree_id : * tree ,
460
- item_tree : & item_tree ,
465
+ macro_depth : depth,
466
+ module_id,
467
+ tree_id,
468
+ item_tree,
461
469
mod_dir,
462
470
}
463
- . collect ( & [ * mod_item] , directive. container ) ;
464
- true
465
- } else {
466
- false
467
- }
468
- } ) ;
469
-
470
- if let Some ( pos) = pos {
471
- unresolved_macros. swap_remove ( pos) ;
472
- }
473
-
474
- self . unresolved_macros . extend ( unresolved_macros) ;
471
+ . collect ( & [ mod_item] , container) ;
475
472
476
- if pos . is_some ( ) {
477
- // Continue name resolution with the new data.
478
- ReachedFixedPoint :: No
479
- } else {
480
- ReachedFixedPoint :: Yes
473
+ self . unresolved_macros . swap_remove ( pos ) ;
474
+ // Continue name resolution with the new data.
475
+ ReachedFixedPoint :: No
476
+ }
477
+ None => ReachedFixedPoint :: Yes ,
481
478
}
482
479
}
483
480
@@ -722,7 +719,8 @@ impl DefCollector<'_> {
722
719
fn resolve_imports ( & mut self ) -> ReachedFixedPoint {
723
720
let mut res = ReachedFixedPoint :: Yes ;
724
721
let imports = mem:: take ( & mut self . unresolved_imports ) ;
725
- let imports = imports
722
+
723
+ self . unresolved_imports = imports
726
724
. into_iter ( )
727
725
. filter_map ( |mut directive| {
728
726
directive. status = self . resolve_import ( directive. module_id , & directive. import ) ;
@@ -742,7 +740,6 @@ impl DefCollector<'_> {
742
740
}
743
741
} )
744
742
. collect ( ) ;
745
- self . unresolved_imports = imports;
746
743
res
747
744
}
748
745
@@ -1034,7 +1031,7 @@ impl DefCollector<'_> {
1034
1031
. glob_imports
1035
1032
. get ( & module_id)
1036
1033
. into_iter ( )
1037
- . flat_map ( |v| v . iter ( ) )
1034
+ . flatten ( )
1038
1035
. filter ( |( glob_importing_module, _) | {
1039
1036
// we know all resolutions have the same visibility (`vis`), so we
1040
1037
// just need to check that once
0 commit comments