-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move binding and scope tracking into a separate ast::Context
struct
#3298
Conversation
8eb23f6
to
f666edb
Compare
|
|
2fe4d67
to
cb54ddc
Compare
Checker
into independent structsast::Context
struct
Okay, this can be merged as-is (in that, it doesn't depend on any additional refactors to be useful). |
How much did the compilation time improved? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM: Something that's unclear to me but isn't something that we need to solve now is how do I decide whether to add some logic to Checker
or Context
? It is my impression that there are still many methods on Checker
that only use state stored on the Context
. Should these be moved to Context
at some point?
type Context<'a> = (Vec<usize>, Vec<RefEquality<'a, Stmt>>); | ||
|
||
#[derive(Default)] | ||
pub struct Deferred<'a> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Can you add some documentation explaining what a Deferred
is? I'm unable to guess its usage from just its name.
The intent is that these should all be moved over to Context. Lemme see if I missed any... |
Yeah just in preparation for future improvements. I don't expect this alone to do much, it's more that it sets us up to be able to split the crate later. |
cb54ddc
to
7b30bae
Compare
This PR is an attempt to split up
Checker
in such a way so as to allow us to break the Ruff linter itself into multiple crates.The first step (seen here) is to remove all AST-visitation state into a new
Context
struct, which tracks the current scope stack, available bindings, etc. By moving these fields and methods off ofChecker
, rules can instead takeContext
as an argument, rather thanChecker
, which means they can be decoupled from the actual "driver" / "visitor" and thereby the rest of the lint rules.