-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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: Include index in Format.getArgument
#18445
base: main
Are you sure you want to change the base?
Conversation
198d94b
to
033cd17
Compare
6cb3ef0
to
0dccbb9
Compare
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.
Copilot reviewed 7 out of 13 changed files in this pull request and generated no comments.
Files not reviewed (6)
- rust/ql/.generated.list: Language not supported
- rust/ql/lib/codeql/rust/AstConsistency.qll: Language not supported
- rust/ql/lib/codeql/rust/controlflow/CfgNodes.qll: Language not supported
- rust/ql/lib/codeql/rust/elements/internal/FormatArgumentImpl.qll: Language not supported
- rust/ql/lib/codeql/rust/elements/internal/FormatImpl.qll: Language not supported
- rust/ql/test/query-tests/diagnostics/AstConsistencyCounts.expected: Language not supported
Tip: If you use Visual Studio Code, you can request a review from Copilot before you push from the "Source Control" tab. Learn more
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.
Thanks for spotting this bug. Not sure what the purpose of argument:
in the schema was. We could also just drop it.
@@ -40,6 +40,16 @@ module Impl { | |||
|
|||
override Format getParent() { result = Synth::TFormat(parent, index, _, _) } | |||
|
|||
/** Gets the position of this argument. */ |
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 predicate might be a bit confusing. I think it should be dropped.
There are named and positional arguments which can be mixed to some extent. Not sure what the "position" of a named argument would mean, and it would be strange if getPosition
does not coincide with the position of a positional argument. For example:
let width = 2;
println!("Value {value:#precision$.0$}", width, precision = 3, value = 100);
would have getPosition() = 2
for 0
.
@@ -42,7 +42,9 @@ module Impl { | |||
|
|||
override int getIndex() { result = index } | |||
|
|||
override FormatArgument getArgument() { result.getParent() = this } | |||
override FormatArgument getArgument(int i) { |
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.
The old definition of getArgument()
was clearly wrong. I think I simply forgot to remove the argument
field from the schema, so we could just delete this predicate. If you want to keep it, that's fine too.
A
Format
can have multipleFormatArgument
s, sogetArgument
must take an index. I have added two new consistency checks as well, one of which (multipleChildren
) would fail prior to this PR.