-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team
Description
crate bar:
pub struct Bar;
pub struct BarNext;
pub trait SomeTrait {
type Next;
}
impl SomeTrait for Bar {
type Next = BarNext;
}
crate foo:
extern crate bar;
struct Foo;
struct Baz;
struct BazNext;
pub trait MyTrait<T> {
}
impl MyTrait<BazNext> for Foo {
}
// Why does this conflict with the previous impl? It should resolve to the type BarNext
impl MyTrait<<::bar::Bar as ::bar::SomeTrait>::Next> for Foo {
}
// Using the type BarNext directly does not conflict with the first impl
// impl MyTrait<::bar::BarNext> for Foo {
// }
fn main() {
println!("Hello, world!");
}
Output:
error[E0119]: conflicting implementations of trait `MyTrait<BazNext>` for type `Foo`:
--> src/main.rs:15:1
|
11 | impl MyTrait<BazNext> for Foo {
| ----------------------------- first implementation here
...
15 | impl MyTrait<<::bar::Bar as ::bar::SomeTrait>::Next> for Foo {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `Foo`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0119`.
error: Could not compile `foo`.
I can only reproduce this issue when using the <Bar as SomeTrait>::Next
syntax, and only when Bar is in an external crate. Reproduced in current stable and nightly.
mtak-, aschampion, phoracek, azrsh, colinjneville and 2 more
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.T-langRelevant to the language teamRelevant to the language team