-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Rust: Crate graph extraction workarounds #19362
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: Crate graph extraction workarounds #19362
Conversation
6919095
to
3ce7728
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 wasn't able to review any files in this pull request.
Files not reviewed (2)
- rust/ql/lib/codeql/rust/internal/PathResolution.qll: Language not supported
- rust/ql/lib/codeql/rust/internal/Type.qll: Language not supported
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 wasn't able to review any files in this pull request.
Files not reviewed (2)
- rust/ql/lib/codeql/rust/internal/PathResolution.qll: Language not supported
- rust/ql/lib/codeql/rust/internal/Type.qll: Language not supported
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.
Really great to get this fixed!
exists(TraitItemNode t | | ||
this = t.getAnAssocItem() and | ||
not this.fromSource() | ||
) |
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.
What about this?
exists(TraitItemNode t | | |
this = t.getAnAssocItem() and | |
not this.fromSource() | |
) | |
not this.fromSource() and | |
this = any(TraitItemNode t).getAnAssocItem() |
( | ||
// when a method exists in both source code and in library code, it is because | ||
// we also extracted the source code as library code, and hence we only want | ||
// the method from source code |
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.
Does this not affect path resolution as well? Could the workaround be done in path resolution? Or is there a benefit to having getASuccessor
give the duplicated methods?
super.hasBody() | ||
or | ||
// for trait items from library code, we do not currently know if they | ||
// have default implementations or not, so we assume they do |
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.
Why do we assume that they have implementations and not the other way around (assume that they don't)?
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.
That is what we did before, and that meant we were unable to resolve such calls
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.
Oh, I see. I would've thought that they'd just be prioritized lower in getStaticTarget
.
exists(TraitItemNode t | | ||
this = t.getAnAssocItem() and | ||
not this.fromSource() | ||
) |
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.
What about this?
exists(TraitItemNode t | | |
this = t.getAnAssocItem() and | |
not this.fromSource() | |
) | |
not this.fromSource() and | |
this = any(TraitItemNode t).getAnAssocItem() |
3ce7728
to
da68329
Compare
da68329
to
52bd99b
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.
Great! Thanks for fixing this and to me it seems nice how it's contained inside path resolution now :)
This PR works around two issues in the crate graph extractor:
core::iter::Iterator
(because that's how it is publicly visible), it generatescore::iter::traits::iterator::Iterator
, which mentions the privatetraits
module.DCA looks great; theMissing call targets
metric goes down for all projects, without significant analysis slowdown.DCA is somewhat mixed, we both gain and lose call edges; the reason why we lose call edges is that functions extracted from the crate graph don't include constraints, so the
isFullyParametric
incorrectly always hold for those.CC: @aibaars