@@ -229,7 +229,8 @@ impl SemanticIndex {
229229 }
230230
231231 /// Whether `scope` runs during the file's own top-level execution, i.e. no
232- /// enclosing scope is lazy.
232+ /// enclosing scope is lazy. Wider than "is the file scope", since a
233+ /// `local()` or `test_that()` body runs at its call site.
233234 pub fn scope_is_eager ( & self , scope_id : ScopeId ) -> bool {
234235 self . enclosing_lazy_scope ( scope_id) . is_none ( )
235236 }
@@ -262,15 +263,6 @@ impl SemanticIndex {
262263 & self . diagnostics
263264 }
264265
265- /// Whether code in `scope` runs during a top-level evaluation of the file.
266- ///
267- /// Wider than "is the file scope": an eager scope like `local()` or
268- /// `test_that()` body runs at its call site. A single lazy scope anywhere
269- /// in the parent chain of `scope` makes it lazy.
270- pub fn is_top_level ( & self , scope : ScopeId ) -> bool {
271- scope_is_top_level ( & self . scopes , scope)
272- }
273-
274266 /// The file-scope names bound by the time the `source()` call at `offset`
275267 /// runs, or `None` if that call sits in a lazy context (a function body),
276268 /// where nothing pins down when it runs.
@@ -449,25 +441,6 @@ impl SemanticIndex {
449441 }
450442}
451443
452- /// Whether `scope` runs during a top-level evaluation of the file: no scope
453- /// from `scope` out to the file root is lazy.
454- ///
455- /// Shared by [`SemanticIndex::is_top_level`] (post-build) and the builder,
456- /// which needs the same walk over its own scope arena mid-build to decide
457- /// whether a `source()` call runs at load time.
458- pub ( crate ) fn scope_is_top_level ( scopes : & IndexVec < ScopeId , Scope > , scope : ScopeId ) -> bool {
459- let mut current = scope;
460- loop {
461- if scopes[ current] . kind . is_lazy ( ) {
462- return false ;
463- }
464- match scopes[ current] . parent {
465- Some ( parent) => current = parent,
466- None => return true ,
467- }
468- }
469- }
470-
471444/// Key for looking up an enclosing snapshot. Keyed by the nested scope and the
472445/// `UseId` of the free variable in that scope, so consumers do an O(1) lookup
473446/// straight from a use without re-walking the ancestor chain.
0 commit comments