@@ -334,7 +334,6 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
334
334
}
335
335
336
336
/// Define the name or return the existing binding if there is a collision.
337
- /// `update` indicates if the definition is a redefinition of an existing binding.
338
337
pub ( crate ) fn try_define_local (
339
338
& mut self ,
340
339
module : Module < ' ra > ,
@@ -352,7 +351,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
352
351
let key = BindingKey :: new_disambiguated ( ident, ns, || {
353
352
( module. 0 . 0 . lazy_resolutions . borrow ( ) . len ( ) + 1 ) . try_into ( ) . unwrap ( )
354
353
} ) ;
355
- self . update_resolution ( module, key, warn_ambiguity, |this, resolution| {
354
+ self . update_local_resolution ( module, key, warn_ambiguity, |this, resolution| {
356
355
if let Some ( old_binding) = resolution. best_binding ( ) {
357
356
if res == Res :: Err && old_binding. res ( ) != Res :: Err {
358
357
// Do not override real bindings with `Res::Err`s from error recovery.
@@ -455,7 +454,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
455
454
456
455
// Use `f` to mutate the resolution of the name in the module.
457
456
// If the resolution becomes a success, define it in the module's glob importers.
458
- fn update_resolution < T , F > (
457
+ fn update_local_resolution < T , F > (
459
458
& mut self ,
460
459
module : Module < ' ra > ,
461
460
key : BindingKey ,
@@ -465,6 +464,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
465
464
where
466
465
F : FnOnce ( & Resolver < ' ra , ' tcx > , & mut NameResolution < ' ra > ) -> T ,
467
466
{
467
+ assert ! ( module. is_local( ) ) ;
468
468
// Ensure that `resolution` isn't borrowed when defining in the module's glob importers,
469
469
// during which the resolution might end up getting re-defined via a glob cycle.
470
470
let ( binding, t, warn_ambiguity) = {
@@ -532,7 +532,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
532
532
// Don't remove underscores from `single_imports`, they were never added.
533
533
if target. name != kw:: Underscore {
534
534
let key = BindingKey :: new ( target, ns) ;
535
- this. update_resolution ( module, key, false , |_, resolution| {
535
+ this. update_local_resolution ( module, key, false , |_, resolution| {
536
536
resolution. single_imports . swap_remove ( & import) ;
537
537
} )
538
538
}
@@ -915,7 +915,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
915
915
// Don't remove underscores from `single_imports`, they were never added.
916
916
if target. name != kw:: Underscore {
917
917
let key = BindingKey :: new ( target, ns) ;
918
- this. update_resolution ( parent, key, false , |_, resolution| {
918
+ this. update_local_resolution ( parent, key, false , |_, resolution| {
919
919
resolution. single_imports . swap_remove ( & import) ;
920
920
} ) ;
921
921
}
0 commit comments