[ty] Don't add incorrect subdiagnostic for unresolved reference (#18487)

Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
Matthew Mckee 2025-06-27 13:40:33 +01:00 committed by GitHub
parent 57bd7d055d
commit a3c79d8170
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 422 additions and 73 deletions

View file

@ -581,7 +581,7 @@ pub enum ScopeKind {
}
impl ScopeKind {
pub(crate) fn is_eager(self) -> bool {
pub(crate) const fn is_eager(self) -> bool {
match self {
ScopeKind::Module | ScopeKind::Class | ScopeKind::Comprehension => true,
ScopeKind::Annotation
@ -591,7 +591,7 @@ impl ScopeKind {
}
}
pub(crate) fn is_function_like(self) -> bool {
pub(crate) const fn is_function_like(self) -> bool {
// Type parameter scopes behave like function scopes in terms of name resolution; CPython
// place table also uses the term "function-like" for these scopes.
matches!(
@ -604,13 +604,17 @@ impl ScopeKind {
)
}
pub(crate) fn is_class(self) -> bool {
pub(crate) const fn is_class(self) -> bool {
matches!(self, ScopeKind::Class)
}
pub(crate) fn is_type_parameter(self) -> bool {
pub(crate) const fn is_type_parameter(self) -> bool {
matches!(self, ScopeKind::Annotation | ScopeKind::TypeAlias)
}
pub(crate) const fn is_non_lambda_function(self) -> bool {
matches!(self, ScopeKind::Function)
}
}
/// [`PlaceExpr`] table for a specific [`Scope`].