Skip to content

Conversation

@clubby789
Copy link
Contributor

@clubby789 clubby789 commented Apr 9, 2025

This adds support for the recently stabilized trait_upcasting feature. Currently, when we cast between non-matching dyn traits, codegen incorrectly reuses the old vtable, leading to confusing issues (#3998).

This reproduces the upcasting logic from upstream rustc to load the vptr when performing the coercion.

Resolves #358
Resolves #3998

This was tested using the motivating example from the linked issue. I will add further tests to make sure this feature is robust.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.

@clubby789 clubby789 requested a review from a team as a code owner April 9, 2025 21:25
@github-actions github-actions bot added the Z-EndToEndBenchCI Tag a PR to run benchmark CI label Apr 9, 2025
@clubby789 clubby789 marked this pull request as draft April 10, 2025 11:16
@clubby789 clubby789 force-pushed the dyn-upcasting branch 3 times, most recently from 4944c63 to 79de96a Compare April 10, 2025 15:00
@clubby789 clubby789 marked this pull request as ready for review April 10, 2025 23:29
Copy link
Contributor

@zhassan-aws zhassan-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks for your contribution! Can you add a reference to the upstream implementation in the code? Otherwise, this is good to go.

@zhassan-aws zhassan-aws enabled auto-merge April 23, 2025 03:45
@zhassan-aws zhassan-aws added this pull request to the merge queue Apr 23, 2025
Merged via the queue into model-checking:main with commit 0aa6c41 Apr 23, 2025
26 of 28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Z-EndToEndBenchCI Tag a PR to run benchmark CI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Trait upcasting doesn't work properly with multiple supertraits Update vtable implementation for upcoming Rust trait upcasting

3 participants