Skip to content

Duplicate 'upstream crates may add a new impl of trait' notes on inter-crate ambiguous impl of traits #99092

Closed
@rhysd

Description

@rhysd

Given the following code:

struct S;

impl From<()> for S {
    fn from(x: ()) -> Self {
        S
    }
}

impl<I> From<I> for S
where
    I: Iterator<Item = ()>,
{
    fn from(x: I) -> Self {
        S
    }
}

fn main() {}

The current output is:

error[E0119]: conflicting implementations of trait `std::convert::From<()>` for type `S`
  --> foo.rs:9:1
   |
3  |   impl From<()> for S {
   |   ------------------- first implementation here
...
9  | / impl<I> From<I> for S
10 | | where
11 | |     I: Iterator<Item = ()>,
12 | | {
...  |
15 | |     }
16 | | }
   | |_^ conflicting implementation for `S`
   |
   = note: upstream crates may add a new impl of trait `std::iter::Iterator` for type `()` in future versions
   = note: upstream crates may add a new impl of trait `std::iter::Iterator` for type `()` in future versions

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.

Ideally the output should look like:

error[E0119]: conflicting implementations of trait `std::convert::From<()>` for type `S`
  --> foo.rs:9:1
   |
3  |   impl From<()> for S {
   |   ------------------- first implementation here
...
9  | / impl<I> From<I> for S
10 | | where
11 | |     I: Iterator<Item = ()>,
12 | | {
...  |
15 | |     }
16 | | }
   | |_^ conflicting implementation for `S`
   |
   = note: upstream crates may add a new impl of trait `std::iter::Iterator` for type `()` in future versions

error: aborting due to previous error

For more information about this error, try `rustc --explain E0119`.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsT-compilerRelevant to the compiler 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