Solver is overzealous with fundamental impls in the standard library
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
More details in this zulip thread detailing the requirements to get ToOwned into core: #t-libs > core::borrow::Cow (cowcore)
Essentially, the impl in question is impl From<Cow<'_, str>> for Box<dyn Error>, where Cow and Error are both defined in core, but alloc defines Box, which is marked fundamental.
It allows this for From<&str> interestingly enough, but not Cow, presumably because it's not a primitive type.
This definitely is totally fine under the orphan rule because core is a dependency of alloc, and thus there would never be any scenario where a impl could be defined in core, even though Box is fundamental.
My guess is that this is a very low-priority bug to fix since this just blocks a change that needs larger stuff to be done first, but this feels like it could potentially show up in other ways if we're not careful, and is worth documenting.
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 with the linked Zulip thread and investigate the compiler's orphan-rule handling for impl From<Cow<'_, str>> for Box<dyn Error>. Compare it with the accepted From<&str> case and determine the intended behavior for fundamental types; completion requires a confirmed fix or documented limitation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100