-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Data flow through trait methods #19881
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
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a4ed5da
Rust: Add data flow tests involving traits
hvitved 5e265b1
Rust: Trait call dispatch in dataflow
hvitved 3e54c61
Rust: Add MaD trait tests
hvitved 8c24039
Rust: Apply MaD trait models to implementations
hvitved 9a48459
Add change note
hvitved File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
--- | ||
category: minorAnalysis | ||
--- | ||
* Implemented support for data flow through trait functions. For the purpose of data flow, calls to trait functions dispatch to all possible implementations. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,8 @@ | |
* - `Field[t(i)]`: position `i` inside the variant/struct with canonical path `v`, for example | ||
* `Field[core::option::Option::Some(0)]`. | ||
* - `Field[i]`: the `i`th element of a tuple. | ||
* - `Reference`: the referenced value. | ||
* - `Future`: the value being computed asynchronously. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good spot. 👍 |
||
* 3. The `kind` column is a tag that can be referenced from QL to determine to | ||
* which classes the interpreted elements should be added. For example, for | ||
* sources `"remote"` indicates a default remote flow source, and for summaries | ||
|
@@ -211,6 +213,10 @@ private class SummarizedCallableFromModel extends SummarizedCallable::Range { | |
this.getCanonicalPath() = path | ||
} | ||
|
||
override predicate hasProvenance(Provenance provenance) { | ||
summaryModel(path, _, _, _, provenance, _) | ||
} | ||
|
||
override predicate propagatesFlow( | ||
string input, string output, boolean preservesValue, string model | ||
) { | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
rust/ql/test/library-tests/dataflow/global/CONSISTENCY/PathResolutionConsistency.expected
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
multipleCallTargets | ||
| main.rs:225:14:225:29 | ...::deref(...) | | ||
| main.rs:272:14:272:29 | ...::deref(...) | |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
[nitpick] The
viableCallable
definition contains deeply nestedexists
andor
expressions; extracting the trait-dispatch logic into a helper predicate could improve readability and maintenance.Copilot uses AI. Check for mistakes.