@@ -315,6 +315,7 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> {
315315 // Records snapshots of the place states visible from the current eager scope.
316316 fn record_eager_snapshots ( & mut self , popped_scope_id : FileScopeId ) {
317317 let popped_scope = & self . scopes [ popped_scope_id] ;
318+ let popped_scope_is_annotation_scope = popped_scope. kind ( ) . is_annotation ( ) ;
318319
319320 // If the scope that we just popped off is an eager scope, we need to "lock" our view of
320321 // which bindings reach each of the uses in the scope. Loop through each enclosing scope,
@@ -330,6 +331,7 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> {
330331 // ```
331332 for enclosing_scope_info in self . scope_stack . iter ( ) . rev ( ) {
332333 let enclosing_scope_id = enclosing_scope_info. file_scope_id ;
334+ let is_immediately_enclosing_scope = popped_scope. parent ( ) == Some ( enclosing_scope_id) ;
333335 let enclosing_scope_kind = self . scopes [ enclosing_scope_id] . kind ( ) ;
334336 let enclosing_place_table = & self . place_tables [ enclosing_scope_id] ;
335337
@@ -352,14 +354,12 @@ impl<'db, 'ast> SemanticIndexBuilder<'db, 'ast> {
352354 nested_scope : popped_scope_id,
353355 nested_laziness : ScopeLaziness :: Eager ,
354356 } ;
355- let is_immediately_enclosing_scope = popped_scope. kind ( ) . is_annotation ( )
356- && popped_scope. parent ( ) == Some ( enclosing_scope_id) ;
357357 let eager_snapshot = self . use_def_maps [ enclosing_scope_id]
358358 . snapshot_enclosing_state (
359359 enclosing_place_id,
360360 enclosing_scope_kind,
361361 enclosing_place,
362- is_immediately_enclosing_scope,
362+ popped_scope_is_annotation_scope && is_immediately_enclosing_scope,
363363 ) ;
364364 self . enclosing_snapshots . insert ( key, eager_snapshot) ;
365365 }
0 commit comments