-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Closed as not planned
Closed as not planned
Copy link
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coherenceArea: CoherenceArea: CoherenceA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.
Description
trait Trait {
type Assoc;
}
struct LocalTy;
impl Trait for () {
type Assoc = LocalTy;
}
impl PartialEq for <() as Trait>::Assoc {
fn eq(&self, other: &Self) -> bool {
true
}
}
results in
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
--> src/lib.rs:10:1
|
10 | impl PartialEq for <() as Trait>::Assoc {
| ^^^^^---------^^^^^--------------------
| | | |
| | | `<() as Trait>::Assoc` is not defined in the current crate
| | `<() as Trait>::Assoc` is not defined in the current crate
| impl doesn't use only types from inside the current crate
|
= note: define and implement a trait or new type instead
ideally it should mention that <() as Trait>::Assoc
may actually be local to the current crate and that the user could replace that projection with the associated type itself.
Metadata
Metadata
Assignees
Labels
A-associated-itemsArea: Associated items (types, constants & functions)Area: Associated items (types, constants & functions)A-coherenceArea: CoherenceArea: CoherenceA-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsT-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.