`try_as_dyn` does not work with builtin impls
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Lifting this from a discussion on Zulip.
core::any::try_as_dyn doesn't work (always returns None) when trying to access builtin impls in any way:
trait SyncAble {}
impl<T> SyncAble for T where T: Sync /* <- builtin */ {}
println!("{}", core::any::try_as_dyn::<u32, dyn SyncAble>(&0).is_some());
Thats quite annoying because checking whether T: Sync holds would potentially allow for optimizations (offloading computations). The same applies to all other builtin impl's. This can be quite confusing, especially because its not consistent for a single trait either.
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
Start by reproducing the example with core::any::try_as_dyn and the linked Rust Playground case. Read the linked Zulip discussion for the intended behavior and constraints around builtin impls. The issue is complete when try_as_dyn handles builtin implementations consistently rather than returning None unexpectedly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100