Closed
Description
I tried this code:
use core::iter::Sum;
struct Summer;
impl Sum<i32> for Summer {
}
I expected to see this happen: an error which either just shows the error itself or the compilable sugestion for change.
Instead, this happened: the error is like following:
error[E0046]: not all trait items implemented, missing: `sum`
--> src/lib.rs:5:1
|
5 | impl Sum<i32> for Summer {
| ^^^^^^^^^^^^^^^^^^^^^^^^ missing `sum` in implementation
|
= help: implement the missing item: `fn sum<I>(_: I) -> Self where I: Iterator, std::iter::Iterator::Item = A { todo!() }`
Now, if I add the code from the help
block into the trait, I'll get another error:
error: equality constraints are not yet supported in `where` clauses
--> src/lib.rs:6:44
|
6 | fn sum<I>(_: I) -> Self where I: Iterator, std::iter::Iterator::Item = A { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not supported
|
= note: [see issue #20041 <https://github.com/rust-lang/rust/issues/20041>](https://github.com/rust-lang/rust/issues/20041) for more information
error[E0412]: cannot find type `A` in this scope
--> src/lib.rs:6:72
|
6 | fn sum<I>(_: I) -> Self where I: Iterator, std::iter::Iterator::Item = A { todo!() }
| - similarly named type parameter `I` defined here ^ help: a type parameter with a similar name exists: `I`
The first one is the one I'm worried about, since it shows that the suggest was using a nightly-only feature on stable.
Noting also that rust-analyzer seems to do this correctly - it creates an intention to insert fn sum<I: Iterator<Item = i32>>(_: I) { todo!(); }
, which compiles immediately.