Open
Description
Note: I’m not sure if anything need to be done since specialization should allow the following code when it will fully be implemented, but currently the quality of the diagnostic is decreased when min_specialization
is used:
Given the following code: playground
trait Trait {
fn foo() {}
fn bar() {}
}
struct Struct<F> {
f: F,
}
impl<F> Trait for Struct<F>
where F: FnMut() -> ()
{
fn foo() {}
}
impl<F> Trait for Struct<F>
where F: FnOnce() -> ()
{
fn bar() {}
}
The current output is:
- With
#![feature(min_specialization)]
error: cannot specialize on trait `FnMut`
--> src/lib.rs:11:1
|
11 | / impl<F> Trait for Struct<F>
12 | | where F: FnMut() -> ()
13 | | {
14 | | fn foo() {}
15 | | }
| |_^
- Without (the diagnostic is much better):
error[[E0119]](https://doc.rust-lang.org/nightly/error-index.html#E0119): conflicting implementations of trait `Trait` for type `Struct<_>`
--> src/lib.rs:17:1
|
11 | / impl<F> Trait for Struct<F>
12 | | where F: FnMut() -> ()
13 | | {
14 | | fn foo() {}
15 | | }
| |_- first implementation here
16 |
17 | / impl<F> Trait for Struct<F>
18 | | where F: FnOnce() -> ()
19 | | {
20 | | fn bar() {}
21 | | }
| |_^ conflicting implementation for `Struct<_>`