type_info: reflection on non-dyn compatible traits
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Right now, if a trait as associated items, reflection is difficult to impossible. My personal case is trying to reflect on an async function. I quickly run into the problem of being unable to determine if a function returns a Future because I have no way of binding Future::Output.
A possible solution that @oli-obk and I brainstormed would be a trait_of! macro, which would take the implementer, plus the trait as an ident, and return a Trait. Further, extensions similar to the below would need to be added around Trait.
pub struct Trait {
// ...
pub associated: &'static [TraitAssocProperty];
}
pub struct TraitAssocProperty {
pub name: &'static str;
pub kind: TraitAssocPropertyKind;
pub ty: TypeId,
}
pub enum TraitAssocPropertyKind {
Constant,
Type
}
Related to: https://github.com/rust-lang/rust/issues/146922 and https://github.com/rust-lang/rust/issues/144361
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No source file, test, or entry point is named. Start by reading the issue and the related issues #146922 and #144361, then clarify the design for trait_of! and associated-item metadata with the maintainers. Done means an agreed reflection design is implemented and its behavior is covered by tests.
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
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100