Skip to content

Using associated types on concrete types as parameters for trait impls causes incorrect type resolution #37832

@dylanede

Description

@dylanede

This small example:

use ::std::borrow::ToOwned;

struct Foo;

impl From<<bool as ToOwned>::Owned> for Foo {
    fn from(v: <bool as ToOwned>::Owned) -> Foo {
        unimplemented!()
    }
}

causes the error E0119: "conflicting implementations of trait std::convert::From<Foo> for type Foo", though I have not written an implementation of From<Foo> anywhere. <bool as ToOwned>::Owned should be synonymous with bool, but in this case it doesn't appear to be, as replacing the first use of the associated type with bool stops the error.

I have observed this on stable, beta, and the latest nightly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-coherenceArea: CoherenceA-type-systemArea: Type systemC-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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions