rust-lang / rust-lang/rust

Can `DynMetadata` be made constructable?

Open
#126,828 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-feature-request T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

Related tracking issue: https://github.com/rust-lang/rust/issues/81513

As of right now, the only way to get a DynMetadata is to call ptr::metadata on an existing pointer, which can create a chicken-and-egg problem. It could be useful to be able to get the metadata for a hypothetical trait object Foo as Trait as well, without first having to construct such a trait object. However, I don't know if this would be possible, and whether it would lead to soundness issues or have other undesired consequences.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading the related tracking issue #81513 and the discussion around DynMetadata and ptr::metadata. Investigate how metadata for a hypothetical trait object could be obtained without an existing pointer, including the stated soundness concerns. Done means establishing whether a constructable API is feasible and defining its intended behavior or documenting why it should not be added.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.