Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rust: Implement type inference for trait objects/dyn types#20084

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
paldepind wants to merge3 commits intogithub:main
base:main
Choose a base branch
Loading
frompaldepind:rust/type-inference-trait-object

Conversation

paldepind
Copy link
Contributor

@paldepindpaldepind commentedJul 17, 2025
edited
Loading

This PR implements support for trait objects on the formdyn Trait.

The implementation works as follows:

  1. Ifdyn Trait appears somewhere as a declared type then we create aDynTraitType that consists of the traitTrait.
  2. Thedyn Trait has a type parameter for every type parameter ofTrait. There is a 1-to-1 correspondence but they're not equal.
  3. Thedyn Trait type is made to implementTrait as 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 theauto 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.

@github-actionsgithub-actionsbot added the RustPull requests that update Rust code labelJul 17, 2025
@paldepindpaldepindforce-pushed therust/type-inference-trait-object branch from59e3ac7 to8de4313CompareJuly 17, 2025 14:14
@paldepindpaldepindforce-pushed therust/type-inference-trait-object branch from8de4313 to55c3674CompareJuly 18, 2025 06:22
@paldepindpaldepindforce-pushed therust/type-inference-trait-object branch from55c3674 to219e26eCompareJuly 18, 2025 07:30
@paldepindpaldepind marked this pull request as ready for reviewJuly 18, 2025 08:18
@paldepindpaldepind requested a review froma team as acode ownerJuly 18, 2025 08:18
@paldepind
Copy link
ContributorAuthor

paldepind commentedJul 18, 2025
edited
Loading

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.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
documentationRustPull requests that update Rust code
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@paldepind

[8]ページ先頭

©2009-2025 Movatter.jp