-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-specializationArea: Trait impl specializationArea: Trait impl specializationC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
The following code fails to compile:
trait Foo {}
auto trait FooAuto {}
impl<T> !FooAuto for T where T: Foo {}
fn test<T>(t: T) where T: FooAuto {}
fn main() {
test(1i32);
}
It produces the following error.
error[E0277]: the trait bound `i32: FooAuto` is not satisfied
--> src/main.rs:11:5
|
10 | test(1i32);
| ^^^^ the trait `FooAuto` is not implemented for `i32`
|
= note: required by `test`
(Playpen)
Even though I restrict the !FooAuto
implementation to types implementing Foo
(which there is none of), the rust compiler does not seem to take that restriction into account. Instead, it removes the FooAuto
auto-implementation from every type.
If I remove the !FooAuto
line, the code compiles just fine.
The same problems happens when I use impl<T: Foo>
instead of where T: Foo
(Playpen).
Also using impl FooAuto for .. {}
instead of auto trait FooAuto
results in the same problem (Playpen).
demurgos and vmarkushin
Metadata
Metadata
Assignees
Labels
A-specializationArea: Trait impl specializationArea: Trait impl specializationC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.