@@ -8,7 +8,7 @@ use rustc_data_structures::intern::Interned;
88use rustc_errors:: codes:: * ;
99use rustc_errors:: { Applicability , MultiSpan , pluralize, struct_span_code_err} ;
1010use rustc_hir:: def:: { self , DefKind , PartialRes } ;
11- use rustc_hir:: def_id:: DefId ;
11+ use rustc_hir:: def_id:: { DefId , LocalDefIdMap } ;
1212use rustc_middle:: metadata:: { ModChild , Reexport } ;
1313use rustc_middle:: span_bug;
1414use rustc_middle:: ty:: Visibility ;
@@ -320,7 +320,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
320320 && ( vis == import_vis
321321 || max_vis. get ( ) . is_none_or ( |max_vis| vis. is_at_least ( max_vis, self . tcx ) ) )
322322 {
323- // FIXME(batched): Will be fixed in batched import resolution.
324323 max_vis. set_unchecked ( Some ( vis. expect_local ( ) ) )
325324 }
326325
@@ -350,7 +349,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
350349 // because they can be fetched by glob imports from those modules, and bring traits
351350 // into scope both directly and through glob imports.
352351 let key = BindingKey :: new_disambiguated ( ident, ns, || {
353- // FIXME(batched): Will be fixed in batched resolution.
354352 module. underscore_disambiguator . update_unchecked ( |d| d + 1 ) ;
355353 module. underscore_disambiguator . get ( )
356354 } ) ;
@@ -470,7 +468,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
470468 // Ensure that `resolution` isn't borrowed when defining in the module's glob importers,
471469 // during which the resolution might end up getting re-defined via a glob cycle.
472470 let ( binding, t, warn_ambiguity) = {
473- let resolution = & mut * self . resolution_or_default ( module, key) . borrow_mut ( ) ;
471+ let resolution = & mut * self . resolution_or_default ( module, key) . borrow_mut_unchecked ( ) ;
474472 let old_binding = resolution. binding ( ) ;
475473
476474 let t = f ( self , resolution) ;
@@ -553,12 +551,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
553551 /// Resolves all imports for the crate. This method performs the fixed-
554552 /// point iteration.
555553 pub ( crate ) fn resolve_imports ( & mut self ) {
556- self . assert_speculative = true ;
557554 let mut prev_indeterminate_count = usize:: MAX ;
558555 let mut indeterminate_count = self . indeterminate_imports . len ( ) * 3 ;
559556 while indeterminate_count < prev_indeterminate_count {
560557 prev_indeterminate_count = indeterminate_count;
561558 indeterminate_count = 0 ;
559+ self . assert_speculative = true ;
562560 for import in mem:: take ( & mut self . indeterminate_imports ) {
563561 let import_indeterminate_count = self . cm ( ) . resolve_import ( import) ;
564562 indeterminate_count += import_indeterminate_count;
@@ -567,14 +565,16 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
567565 _ => self . indeterminate_imports . push ( import) ,
568566 }
569567 }
568+ self . assert_speculative = false ;
570569 }
571- self . assert_speculative = false ;
572570 }
573571
574572 pub ( crate ) fn finalize_imports ( & mut self ) {
575- for module in self . arenas . local_modules ( ) . iter ( ) {
576- self . finalize_resolutions_in ( * module) ;
573+ let mut module_children = Default :: default ( ) ;
574+ for module in & self . local_modules {
575+ self . finalize_resolutions_in ( * module, & mut module_children) ;
577576 }
577+ self . module_children = module_children;
578578
579579 let mut seen_spans = FxHashSet :: default ( ) ;
580580 let mut errors = vec ! [ ] ;
@@ -651,7 +651,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
651651 }
652652
653653 pub ( crate ) fn lint_reexports ( & mut self , exported_ambiguities : FxHashSet < NameBinding < ' ra > > ) {
654- for module in self . arenas . local_modules ( ) . iter ( ) {
654+ for module in & self . local_modules {
655655 for ( key, resolution) in self . resolutions ( * module) . borrow ( ) . iter ( ) {
656656 let resolution = resolution. borrow ( ) ;
657657 let Some ( binding) = resolution. best_binding ( ) else { continue } ;
@@ -860,15 +860,12 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
860860 }
861861 } ;
862862
863- // FIXME(batched): Will be fixed in batched import resolution.
864863 import. imported_module . set_unchecked ( Some ( module) ) ;
865864 let ( source, target, bindings, type_ns_only) = match import. kind {
866865 ImportKind :: Single { source, target, ref bindings, type_ns_only, .. } => {
867866 ( source, target, bindings, type_ns_only)
868867 }
869868 ImportKind :: Glob { .. } => {
870- // FIXME: Use mutable resolver directly as a hack, this should be an output of
871- // speculative resolution.
872869 self . get_mut_unchecked ( ) . resolve_glob_import ( import) ;
873870 return 0 ;
874871 }
@@ -904,8 +901,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
904901 }
905902 // We need the `target`, `source` can be extracted.
906903 let imported_binding = this. import ( binding, import) ;
907- // FIXME: Use mutable resolver directly as a hack, this should be an output of
908- // speculative resolution.
909904 this. get_mut_unchecked ( ) . define_binding_local (
910905 parent,
911906 target,
@@ -918,8 +913,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
918913 // Don't remove underscores from `single_imports`, they were never added.
919914 if target. name != kw:: Underscore {
920915 let key = BindingKey :: new ( target, ns) ;
921- // FIXME: Use mutable resolver directly as a hack, this should be an output of
922- // speculative resolution.
923916 this. get_mut_unchecked ( ) . update_local_resolution (
924917 parent,
925918 key,
@@ -936,7 +929,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
936929 PendingBinding :: Pending
937930 }
938931 } ;
939- // FIXME(batched): Will be fixed in batched import resolution.
940932 bindings[ ns] . set_unchecked ( binding) ;
941933 }
942934 } ) ;
@@ -1548,7 +1540,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15481540
15491541 // Miscellaneous post-processing, including recording re-exports,
15501542 // reporting conflicts, and reporting unresolved imports.
1551- fn finalize_resolutions_in ( & mut self , module : Module < ' ra > ) {
1543+ fn finalize_resolutions_in (
1544+ & self ,
1545+ module : Module < ' ra > ,
1546+ module_children : & mut LocalDefIdMap < Vec < ModChild > > ,
1547+ ) {
15521548 // Since import resolution is finished, globs will not define any more names.
15531549 * module. globs . borrow_mut ( self ) = Vec :: new ( ) ;
15541550
@@ -1573,7 +1569,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
15731569
15741570 if !children. is_empty ( ) {
15751571 // Should be fine because this code is only called for local modules.
1576- self . module_children . insert ( def_id. expect_local ( ) , children) ;
1572+ module_children. insert ( def_id. expect_local ( ) , children) ;
15771573 }
15781574 }
15791575}
0 commit comments