Rust: Implement type inference for trait objects/dyn types#20084
Merged
paldepind merged 4 commits intogithub:mainfrom Jul 24, 2025
Merged
Rust: Implement type inference for trait objects/dyn types#20084paldepind merged 4 commits intogithub:mainfrom
dyn types#20084paldepind merged 4 commits intogithub:mainfrom
Conversation
59e3ac7 to
8de4313
Compare
55c3674 to
219e26e
Compare
Contributor
Author
|
Note: The first DCA run showed an increase in type inference inconsistencies. I've fixed those and started a second DCA run. EDIT: The second DCA shows that the type inference inconsistencies are now fixed. The number of type inference inconsistencies now only decreases. |
e301fd5 to
f5605c9
Compare
geoffw0
reviewed
Jul 23, 2025
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
QL LGTM, though I didn't quite follow every detail in TypeMention.qll. Tests look great. I'm looking at the DCA run as well but it looks like you've already fixed an issue there.
geoffw0
approved these changes
Jul 24, 2025
Contributor
geoffw0
left a comment
There was a problem hiding this comment.
Questions and concerns addressed, LGTM!
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This PR implements support for trait objects on the form
dyn Trait.The implementation works as follows:
dyn Traitappears somewhere as a declared type then we create aDynTraitTypethat consists of the traitTrait.dyn Traithas a type parameter for every type parameter ofTrait. There is a 1-to-1 correspondence but they're not equal.dyn Traittype is made to implementTraitas if there was animpl<A, B, ...> Trait<A, B, ...> for dyn Trait<A, B, ..>block in the source.Currently the PR doesn't account for the auto traits that one can specify with a
+, for instancedyn Clone + Send + Sync. I don't know if we have a need to consider those, but if we do it should be possible by building on top of the work in this PR.DCA shows a 0.33% point increase in resolved call targets and no change in analysis time.