Skip to content

Conversation

@ssyram
Copy link
Owner

@ssyram ssyram commented Sep 3, 2025

This is to contribute to AeneasVerif#762 to add vtable support for closures.

Basically, the required changes are:

  • Add correct registration of closure vtable support in translate_rvalue in file translate_bodies.rs.
  • Correctly handle and add the closure support in translate_trait_objects.rs to add the vtable instance support.
    • Note to refer to the correct TraitImplRef for the vtable instance, referring to the translated closure impl.
    • Implement the correct method shim for call, call_once & call_mut when required.
    • Make sure that the vtable metadata pass (compute_vtable_metadata.rs) works correctly for also the closures case.

For the first phase, the mechanism should be closely related to the current mechanism of translating closures in translate_closures.rs and the calls to this module. More importantly, to make sure that it works well with the second phase of implementing vtable instance, the registration should put something whose FullDef is a hax::FullDefKind::Closure.

For the last case for the vtable metadata pass. If the Drop is automatically implemented & extracted for the closures, this is straightfoward and needs no extra handling. Otherwise, if the drop shim is to implement by hand, this involves a similar mechanism like the Tuple case.

@ssyram ssyram marked this pull request as draft September 3, 2025 07:57
Copilot AI and others added 9 commits September 3, 2025 08:11
…s.rs

Co-authored-by: ssyram <23273765+ssyram@users.noreply.github.com>
Co-authored-by: ssyram <23273765+ssyram@users.noreply.github.com>
…ion issues

Co-authored-by: ssyram <23273765+ssyram@users.noreply.github.com>
Now all tests passed, but the methods & parent pointers are still placeholders to be generated.
@ssyram ssyram marked this pull request as ready for review September 5, 2025 10:04
Copilot AI and others added 2 commits September 5, 2025 23:05
* Initial plan

* Initial analysis: Identify missing supertrait vtable registration issue

Co-authored-by: ssyram <23273765+ssyram@users.noreply.github.com>

* Partial fix: Successfully handle closure supertrait vtables

Co-authored-by: ssyram <23273765+ssyram@users.noreply.github.com>

* Complete fix: Handle both closure and marker trait supertrait vtables

Co-authored-by: ssyram <23273765+ssyram@users.noreply.github.com>

* parent traits done

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ssyram <23273765+ssyram@users.noreply.github.com>
Co-authored-by: ssyram <liguany126@126.com>
@ssyram ssyram merged commit 8778c91 into main Sep 5, 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