[ty] Add comment explaining why `HasTrackedScope` is implemented for `Identifier` and why it works (#21057)

This commit is contained in:
Micha Reiser 2025-10-24 09:48:57 +02:00 committed by GitHub
parent be5a62f7e5
commit 4522f35ea7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 4 additions and 2 deletions

View File

@ -505,8 +505,10 @@ impl HasTrackedScope for ast::Expr {}
impl HasTrackedScope for ast::ExprRef<'_> {} impl HasTrackedScope for ast::ExprRef<'_> {}
impl HasTrackedScope for &ast::ExprRef<'_> {} impl HasTrackedScope for &ast::ExprRef<'_> {}
// See https://github.com/astral-sh/ty/issues/572 why this implementation exists // We never explicitly register the scope of an `Identifier`.
// even when we never register identifiers during semantic index building. // However, `ExpressionsScopeMap` stores the text ranges of each scope.
// That allows us to look up the identifier's scope for as long as it's
// inside an expression (because the ranges overlap).
impl HasTrackedScope for ast::Identifier {} impl HasTrackedScope for ast::Identifier {}
#[cfg(test)] #[cfg(test)]