mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-10 05:39:12 +00:00
Move a few more candidate rules to the deferred Binding
-only pass (#5853)
## Summary No behavior change, but this is in theory more efficient, since we can just iterate over the flat `Binding` vector rather than having to iterate over binding chains via the `Scope`.
This commit is contained in:
parent
626d8dc2cc
commit
1181d25e5a
5 changed files with 86 additions and 81 deletions
|
@ -17,6 +17,8 @@ use crate::ScopeId;
|
|||
pub struct Binding<'a> {
|
||||
pub kind: BindingKind<'a>,
|
||||
pub range: TextRange,
|
||||
/// The [`ScopeId`] of the scope in which the [`Binding`] was defined.
|
||||
pub scope: ScopeId,
|
||||
/// The context in which the [`Binding`] was created.
|
||||
pub context: ExecutionContext,
|
||||
/// The statement in which the [`Binding`] was defined.
|
||||
|
|
|
@ -189,6 +189,7 @@ impl<'a> SemanticModel<'a> {
|
|||
self.bindings.push(Binding {
|
||||
range: TextRange::default(),
|
||||
kind: BindingKind::Builtin,
|
||||
scope: ScopeId::global(),
|
||||
references: Vec::new(),
|
||||
flags: BindingFlags::empty(),
|
||||
source: None,
|
||||
|
@ -209,6 +210,7 @@ impl<'a> SemanticModel<'a> {
|
|||
kind,
|
||||
flags,
|
||||
references: Vec::new(),
|
||||
scope: self.scope_id,
|
||||
source: self.stmt_id,
|
||||
context: self.execution_context(),
|
||||
exceptions: self.exceptions(),
|
||||
|
@ -795,6 +797,7 @@ impl<'a> SemanticModel<'a> {
|
|||
kind: BindingKind::Assignment,
|
||||
range: *range,
|
||||
references: Vec::new(),
|
||||
scope: self.scope_id,
|
||||
source: self.stmt_id,
|
||||
context: self.execution_context(),
|
||||
exceptions: self.exceptions(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue