-
Notifications
You must be signed in to change notification settings - Fork 5
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
Lint 6: duplicate-mutable-accounts #6
base: master
Are you sure you want to change the base?
Conversation
Completed upgrade so lint can effectively handle cases where number of identical accounts > 2. All tests pass except for |
8d83daa
to
d0c2455
Compare
/// represent the identifiers being compared. Following the previous example, this would be `(a, b)`. | ||
fn generate_possible_expected_constraints( | ||
identical_types: &[(Symbol, Span)], | ||
) -> Vec<((TokenStream, TokenStream), (Symbol, Symbol))> { |
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.
add closure argument to do comparison in function to not have to store generated streams
e42f644
to
12caca7
Compare
@smoelius lint 6 is completely done as it stands. Only small thing that is bugging me (and this is personal preference) is that when there are no key checks at all (not using anchor macro constraints, nor alternate constraints such as in function bodies), then the lint will print messages related to the v2 lint I wrote, which doesn't have as nice messages. This is due to some of the logic of the program, and its fairly involved to change it than one might think. Ideally, if no constraints are in the program at all, I would have liked for the lint to print the v1 messages, ie, the one that recommends adding the |
also if there's too many commits, I can squash |
|
@victor-wei126 Can you sign the CLA? |
fn is_substream(stream: &TokenStream, other: &TokenStream) -> bool { | ||
let other_len = other.len(); | ||
for i in 0..stream.len() { | ||
for (j, other_token) in other.trees().enumerate() { |
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.
I have a hunch this could be written more simply as:
if other.trees().enumerate().all(|(j, other_token)| { ... }) {
return true;
}
e8b0ab4
to
bbbb0a9
Compare
94b6cf5
to
85a445b
Compare
85a445b
to
e3d777b
Compare
for next in current + 1..exprs.len() { | ||
if values.check_key_constraint(exprs[current], exprs[next]) { | ||
// if there is at least one alt constraint, set flag to false | ||
self.no_alternate_constraints = false; |
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.
This could flip back to true
if the program contains more than one function, right? (Or am I misunderstanding?)
I'm wondering if no_alternate_constraints
and spans
should be maintained per function, similar to how anchor_accounts
is maintained per struct def.
Quick and somewhat-dirty implementation of lint 6. Tests pass, but may need further work/clean-up when encountering >2 duplicate accounts.