Open
Description
The following code:
#![feature(specialization)]
struct BadStruct {
err: MissingType
}
trait MyTrait<T> {
fn foo();
}
impl<T, D> MyTrait<T> for D {
default fn foo() {}
}
impl<T> MyTrait<T> for BadStruct {
fn foo() {}
}
gives the following errors:
error[E0412]: cannot find type `MissingType` in this scope
--> src/lib.rs:4:10
|
4 | err: MissingType
| ^^^^^^^^^^^ not found in this scope
error[E0119]: conflicting implementations of trait `MyTrait<_>` for type `BadStruct`:
--> src/lib.rs:15:1
|
11 | impl<T, D> MyTrait<T> for D {
| --------------------------- first implementation here
...
15 | impl<T> MyTrait<T> for BadStruct {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `BadStruct`
error: aborting due to 2 previous errors
For some reason, the fact that the definition of BadStruct
has an error (MissingType
is not defining) causes a 'conflicting implementations' error to be emitted when BadStruct
has a specialized impl. If MissingType
is changed to a type which actually exists (e.g. ()
), the 'conflicting implementations' error disappears.
I found this when working on rustc
- a missing use
statement caused 30 spurious specialization-related errors to be emiited, which all disappeared when I added the missing import.
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Trait impl specializationCategory: This is a bug.Diagnostics: Too much output caused by a single piece of incorrect code.Call for participation: An issue has been fixed and does not reproduce, but no test has been added.`#![feature(specialization)]`Relevant to the compiler team, which will review and decide on the PR/issue.