Skip to content

Tracking issue for dyn-star #102425

Closed

Description

@eholk

This issue tracks known issues or missing functionality with support for dyn* Trait objects. These are an experimental feature that are meant to support async function in dyn traits.

In addition to the issues linked here, you can also find things that need to be done by greping the code for // FIXME(dyn-star) or looking at the F-dyn_star label.

Associated PRs

About this issue

This is a lang-team experiment -- there hasn't been an RFC for this functionality, we're exploring it both as a potential implementation detail and (more speculatively) a possible language feature in the future. You can read more about dyn* at this blog post.

Lang-team champion: @nikomatsakis

Activity

  1. Rageking8 commented on Sep 29, 2022

    @Rageking8
    Contributor

    @rustbot label +C-tracking-issue

  2. added
    C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFC
    on Sep 29, 2022
  3. moved this to Experimental in Initiativeson Oct 4, 2022
  4. self-assigned this
    on Oct 4, 2022
  5. added a commit that references this issue on Nov 21, 2022
  6. added a commit that references this issue on Jan 1, 2023
  7. RalfJung commented on Feb 6, 2023

    @RalfJung
    Member

    Currently the dynamic type hidden by dyn* is required to match usize in size and alignment. In principle it seems possible to allow smaller alignment, and possibly even smaller size (though in the latter case care has to be taken that the vtable always ends up at the same offset -- this would be easier if the vtable was the first component of the pair, not the 2nd). Are there plans to allow that?

  8. ds84182 commented on Feb 6, 2023

    @ds84182

    Right now you can actually place smaller size & align types with dyn* by stuffing it inside a usize with a little bit of unsafe. Due to the existing alignment requirements for the vtable ptr, it will always end up at the same offset as long as size_of::<T>() <= size_of::<usize>() && align_of::<T>() <= align_of::<usize>().

  9. RalfJung commented on Feb 6, 2023

    @RalfJung
    Member

    Due to the existing alignment requirements for the vtable ptr, it will always end up at the same offset as long as size_of::() <= size_of::() && align_of::() <= align_of::().

    This is not true for size_of::<T>() == 0. Also, this assumes that for a usize (and pointers), size == align.

  10. ds84182 commented on Feb 6, 2023

    @ds84182

    This is not true for size_of::<T>() == 0. Also, this assumes that for a usize (and pointers), size == align.

    Ah, right. I guess a better way to describe the requirements is something like

    union DynStarCompatible<T> {
      true_value: T,
      size_align: usize,
    }

    where DynStarCompatible<T> matches the size and align of usize. (of course, this still has the same assumption about usize and ptrs, but this could be trivially replaced with *const ())

  11. eholk commented on Feb 7, 2023

    @eholk
    ContributorAuthor

    Currently the dynamic type hidden by dyn* is required to match usize in size and alignment. In principle it seems possible to allow smaller alignment, and possibly even smaller size (though in the latter case care has to be taken that the vtable always ends up at the same offset -- this would be easier if the vtable was the first component of the pair, not the 2nd). Are there plans to allow that?

    Yes, this is something I would like to support.

  12. RalfJung commented on Feb 10, 2023

    @RalfJung
    Member

    From the initial PR:

    Note that this is never intended to become stable surface syntax for Rust, but rather dyn* is planned to be used as an implementation detail for async functions in dyn traits.

    Honestly that seems like a shame -- this could be useful way beyond async fn I think. (But then there are other proposals that are even more general so indeed stabilizing this particular one might be the wrong call.)

  13. 20 remaining items

  14. added a commit that references this issue on Dec 22, 2024
  15. added a commit that references this issue on Dec 22, 2024
  16. added a commit that references this issue on Dec 23, 2024
  17. added a commit that references this issue on Mar 11, 2025
  18. added a commit that references this issue on Jun 27, 2025
  19. added a commit that references this issue on Jul 1, 2025
  20. moved this from Experimental to Feature Complete in Initiativeson Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

B-experimentalBlocker: In-tree experiment; RFC pending, not yet approved or unneeded (requires FCP to stabilize).C-tracking-issueCategory: An issue tracking the progress of sth. like the implementation of an RFCF-dyn_star`#![feature(dyn_star)]`T-langRelevant to the language team

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions