-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-trait-systemArea: Trait systemArea: Trait systemT-langRelevant to the language teamRelevant to the language team
Description
Implementing a Trait for a type T (where T is a function with a given a signature) and then trying to implement the same trait for another type T (where T is a function with a different signature) doesn't compile.
I tried this code:
trait MyTrait {}
impl<F> MyTrait for F where F: Fn(u32) -> u32 {}
impl<F> MyTrait for F where F: Fn(u32, u32) -> u32 {}
When compiling this code I get :
error[E0119]: conflicting implementations of trait `MyTrait`:
--> src/main.rs:5:1
|
3 | impl<F> MyTrait for F where F: Fn(u32) -> u32 {}
| ------------------------------------------------------ first implementation here
4 |
5 | impl<F> MyTrait for F where F: Fn(u32, u32) -> u32 {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation
What I would expect is that T here represent in the first implementation either a fn(u32) -> u32 or a closure the implement Fn(u32) -> u32, then in the second implementation, T would be either a fn(u32, u32) -> u32 or a closure the implement Fn(u32, u32) -> u32.
Meta
rustc 1.34.0 (91856ed 2019-04-10)
binary: rustc
commit-hash: 91856ed
commit-date: 2019-04-10
host: x86_64-apple-darwin
release: 1.34.0
LLVM version: 8.0
elipsitz, aWeinzierl, dzmitry-lahoda, geo-ant, ebkalderon and 4 moredzmitry-lahoda and geo-ant
Metadata
Metadata
Assignees
Labels
A-closuresArea: Closures (`|…| { … }`)Area: Closures (`|…| { … }`)A-trait-systemArea: Trait systemArea: Trait systemT-langRelevant to the language teamRelevant to the language team