Skip to content

Conversation

@hvitved
Copy link
Contributor

@hvitved hvitved commented Jan 13, 2025

No description provided.

@github-actions github-actions bot added the Rust Pull requests that update Rust code label Jan 13, 2025
@hvitved hvitved force-pushed the rust/nested-functions branch from 50f80f2 to 1bbb3fd Compare January 15, 2025 08:45
@hvitved hvitved marked this pull request as ready for review January 15, 2025 12:18
@hvitved hvitved requested review from Copilot and paldepind January 15, 2025 12:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 9 changed files in this pull request and generated no comments.

Files not reviewed (4)
  • rust/ql/lib/codeql/rust/elements/internal/VariableImpl.qll: Language not supported
  • rust/ql/test/library-tests/dataflow/global/inline-flow.expected: Language not supported
  • rust/ql/test/library-tests/dataflow/global/viableCallable.expected: Language not supported
  • rust/ql/test/library-tests/variables/variables.ql: Language not supported

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more


{
print_i64(f(4)); // $ SPURIOUS: read_access=f1
print_i64(f(4));
Copy link
Contributor

Choose a reason for hiding this comment

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

Am I understanding correctly that the Rust scoping rules are slightly different for nested functions vs variables - it looks like nested functions are treated as though they're at the beginning of whichever block they're in whereas variables retain their place, then an access binds to the nearest decl above it.

If so the test changes LGTM. The spurious result we had on line 351 certainly made no sense any way I look at it.

(I've briefly looked at the QL as well and saw no problems, but this library isn't really my area)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Am I understanding correctly that the Rust scoping rules are slightly different for nested functions vs variables - it looks like nested functions are treated as though they're at the beginning of whichever block they're in whereas variables retain their place, then an access binds to the nearest decl above it.

Correct.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks.

I'll approve the PR since nobody else is rushing to give a review. :)

@hvitved hvitved merged commit 10f5513 into github:main Jan 24, 2025
16 checks passed
@hvitved hvitved deleted the rust/nested-functions branch January 24, 2025 07:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants