Skip to content

Conversation

@ssyram
Copy link
Contributor

@ssyram ssyram commented Sep 15, 2025

This PR is split from #762 . It contains the part of the implementation for supporting vtable instances. For each concrete casting from &T to &dyn Trait, a global static {impl Trait for T}::{vtable} will be generated, which initialises the method fields with the method shims --- notably, when one calls a method from &dyn Trait, the receiver is &dyn Trait instead of the concrete type &T. This requires a bridging method that uses a Concretize cast to cast back from &dyn Trait to &T and then call the correct method within the user-defined impl Trait for T.

Note that this PR does not handle the virtual implementations, e.g., closures --- there is no explicit impl Fn for CLOSURE that is defined by the user. This will be fixed in the up-coming PR split from #762 .

Also, in this PR, the metadata fields of the vtable instances, i.e., the size, align and drop fields are not translated and are currently Opaque. This will also be partly alleviated in the up-coming PR from #762 .

ci: use AeneasVerif/aeneas#619
ci: use AeneasVerif/eurydice#294

Copy link
Member

@Nadrieril Nadrieril left a comment

Choose a reason for hiding this comment

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

Overall looks pretty good, ty! Marking it as draft while you address the comments.

@Nadrieril Nadrieril marked this pull request as draft September 16, 2025 14:03
@ssyram
Copy link
Contributor Author

ssyram commented Oct 2, 2025

Fixed the dyn_receiver -> dyn_sig following the AeneasVerif/hax#4 .

@Nadrieril
Copy link
Member

Nadrieril commented Oct 2, 2025

I renamed dyn_sig to vtable_sig since, and am merging that small change here: #829. Once that is merged could you update your PR?

@ssyram
Copy link
Contributor Author

ssyram commented Oct 2, 2025

OK, I will try to implement it.

@ssyram
Copy link
Contributor Author

ssyram commented Oct 2, 2025

OK, updated.

@ssyram ssyram force-pushed the dyn-trait-instance branch from a5662db to cda7046 Compare October 2, 2025 12:41
@Nadrieril
Copy link
Member

Sorry I just created merge conflicts for you again

@Nadrieril Nadrieril marked this pull request as ready for review October 2, 2025 15:14
Nadrieril and others added 4 commits October 3, 2025 15:40
Co-authored-by: ssyram <liguany126@126.com>
Co-authored-by: ssyram <liguany126@126.com>
Co-authored-by: ssyram <liguany126@126.com>
Co-authored-by: ssyram <liguany126@126.com>
@Nadrieril Nadrieril force-pushed the dyn-trait-instance branch 2 times, most recently from 06a7b80 to e84b41e Compare October 3, 2025 14:44
@Nadrieril Nadrieril changed the title Instances for dyn Trait Translate dyn Trait method shims Oct 3, 2025
Co-authored-by: ssyram <liguany126@126.com>
@Nadrieril Nadrieril enabled auto-merge October 3, 2025 14:56
@Nadrieril Nadrieril added this pull request to the merge queue Oct 3, 2025
Merged via the queue into AeneasVerif:main with commit 234c07a Oct 3, 2025
11 of 14 checks passed
@ssyram ssyram mentioned this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants