Skip to content
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

Rust: Account for captured variables #17696

Merged
merged 4 commits into from
Oct 9, 2024

Conversation

hvitved
Copy link
Contributor

@hvitved hvitved commented Oct 8, 2024

Add AST logic for identifying captured variables.

I identified and fixed two bugs as well:

  • Actually use the inner scope in variableAccessCandInScope, as the comment says.
  • Account for rank being potentially non-dense, by applying a newly introduced DenseRank library.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Oct 8, 2024
@hvitved hvitved force-pushed the rust/captured-variables branch from 381caf9 to 5afd2d5 Compare October 9, 2024 08:17
@hvitved hvitved marked this pull request as ready for review October 9, 2024 08:45
@hvitved hvitved added the no-change-note-required This PR does not need a change note label Oct 9, 2024
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code and results LGTM. Couple of nits.

shared/util/codeql/util/DenseRank.qll Outdated Show resolved Hide resolved
shared/util/codeql/util/DenseRank.qll Show resolved Hide resolved
shared/util/codeql/util/DenseRank.qll Show resolved Hide resolved
@hvitved hvitved requested a review from geoffw0 October 9, 2024 15:22
Copy link
Contributor

@geoffw0 geoffw0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

@hvitved hvitved merged commit 6a87eb0 into github:main Oct 9, 2024
36 checks passed
@hvitved hvitved deleted the rust/captured-variables branch October 9, 2024 17:42
}

/** Same as `DenseRank`, but allows for a context consisting of one element. */
module DenseRank2<DenseRankInputSig2 Input> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would the naming perhaps be a bit better if the numbering was shifted? I.e. DenseRank1 here to indicate a size one context?

}

/** Gets the dense rank of `r` in the context provided by `c1` and `c2`. */
int denseRank(C1 c1, C2 c2, Ranked r) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think perhaps I would have swapped the rank and the Ranked columns, so the Ranked would be the result, same as with the builtin aggregate.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether to similarly swap in the input predicate, I don't know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-change-note-required This PR does not need a change note Rust Pull requests that update Rust code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants