Skip to content

Solver is overzealous with fundamental impls in the standard library #157498

@clarfonthey

Description

@clarfonthey

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coherenceArea: CoherenceC-bugCategory: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-typesRelevant to the types team, which will review and decide on the PR/issue.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions