-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: extract generic parameters, arguments and resolve bound type variables #19237
base: main
Are you sure you want to change the base?
Conversation
Enum variants cannot be declared as a module item, they can only be imported
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.
Pull Request Overview
This PR aims to support the extraction of generic parameters, arguments, and the resolution of bound type variables in Rust. It introduces two new generic structs (LocalKey and Thing) and implements a From trait conversion for Thing instantiated with type X.
Files not reviewed (3)
- rust/ql/lib/codeql/rust/elements/internal/LifetimeImpl.qll: Language not supported
- rust/ql/test/extractor-tests/crate_graph/modules.expected: Language not supported
- rust/ql/test/extractor-tests/crate_graph/modules.ql: Language not supported
Comments suppressed due to low confidence (2)
rust/ql/test/extractor-tests/crate_graph/module.rs:47
- [nitpick] The struct name 'LocalKey' is ambiguous; consider renaming it or adding a doc comment to clarify its purpose.
pub struct LocalKey<T: 'static> {
rust/ql/test/extractor-tests/crate_graph/module.rs:48
- [nitpick] Consider renaming the field 'inner' to a more descriptive name that reflects its functionality to improve code readability.
inner: fn(Option<&mut Option<T>>) -> *const T,
cb7b4a6
to
5178925
Compare
70e9c22
to
5c67429
Compare
5c67429
to
df5f003
Compare
@@ -319,6 +319,13 @@ resolvePath | |||
| my.rs:18:9:18:11 | my4 | my.rs:14:1:16:1 | mod my4 | | |||
| my.rs:18:9:18:16 | ...::my5 | my.rs:15:5:15:16 | mod my5 | | |||
| my.rs:18:9:18:19 | ...::f | my/my4/my5/mod.rs:1:1:3:1 | fn f | | |||
| my.rs:22:5:22:9 | std | file:///Users/arthur/.rustup/toolchains/1.85-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/lib.rs:0:0:0:0 | Crate(std@0.0.0) | |
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.
Looks like we should add an i.fromSource()
conjunct to query predicate resolvePath
.
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 took the following approach a2844cc . Just dropping the results by filtering with i.fromSource()
also works. Or perhaps simply set the location to "no location" for things that are not from source. I think it would still be useful to record that std
was resolved to Crate(std)
, though the file path is not too relevant.
@@ -178,7 +178,7 @@ abstract class ItemNode extends Locatable { | |||
Stages::PathResolutionStage::ref() and | |||
result = this.getASuccessorRec(name) | |||
or | |||
preludeEdge(this, name, result) | |||
preludeEdge(this, name, result) and not declares(this, _, name) |
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.
LGTM, but let's do it in its own PR (as you suggested offline).
No description provided.