Skip to content

Blanket impls constrained by different associated types falsely flagged as conflicting #86605

Closed
@boringcactus

Description

@boringcactus

I tried this code (aggressively simplified from Diesel, with which I originally encountered this bug):

trait Backend {
    type RawValue;
}

trait FromSql<B: Backend> {}

impl<B: Backend<RawValue=()>> FromSql<B> for String {}
impl<B: Backend<RawValue=u8>> FromSql<B> for String {}

I expected to see this happen: this code compiles, because by definition nothing can implement both Backend<RawValue=()> and Backend<RawValue=u8>.

Instead, this happened: rustc gives error[E0119]: conflicting implementations of trait 'FromSql<_>' for type 'std::string::String'

Meta

This happens across stable/beta/nightly on the Rust playground.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: This is a bug.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions