Closed
Description
Given the following code:
struct Foo;
impl Extend<u8> for Foo {
}
fn main() {
}
The current output is:
error[E0046]: not all trait items implemented, missing: `extend`
--> main.rs:3:1
|
3 | impl Extend<u8> for Foo {
| ^^^^^^^^^^^^^^^^^^^^^^^ missing `extend` in implementation
|
= help: implement the missing item: `fn extend<T>(&mut self, _: T) where T: IntoIterator, std::iter::IntoIterator::Item = A { todo!() }`
error: aborting due to previous error
Following the suggestion given:
struct Foo;
impl Extend<u8> for Foo {
fn extend<T>(&mut self, _: T) where T: IntoIterator, std::iter::IntoIterator::Item = A { todo!() }
}
fn main() {
}
two additional errors are raised:
error: equality constraints are not yet supported in `where` clauses
--> src/main.rs:4:58
|
4 | fn extend<T>(&mut self, _: T) where T: IntoIterator, std::iter::IntoIterator::Item = A { todo!() }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not supported
|
= note: see issue #20041 <https://github.com/rust-lang/rust/issues/20041> for more information
error[E0412]: cannot find type `A` in this scope
--> src/main.rs:4:90
|
4 | fn extend<T>(&mut self, _: T) where T: IntoIterator, std::iter::IntoIterator::Item = A { todo!() }
| - similarly named type parameter `T` defined here ^ help: a type parameter with a similar name exists: `T`
These errors are fixable like so:
struct Foo;
impl Extend<u8> for Foo {
fn extend<T>(&mut self, _: T) where T: IntoIterator<Item = u8> { todo!() }
}
fn main() {
}
This issue is present on both stable and nightly:
$ rustc --version --verbose
rustc 1.56.1 (59eed8a2a 2021-11-01)
binary: rustc
commit-hash: 59eed8a2aac0230a8b53e89d4e99d55912ba6b35
commit-date: 2021-11-01
host: x86_64-unknown-linux-gnu
release: 1.56.1
LLVM version: 13.0.0
$ rustc --version --verbose
rustc 1.58.0-nightly (c9c4b5d72 2021-11-17)
binary: rustc
commit-hash: c9c4b5d7276297679387189d96a952f2b760e7ad
commit-date: 2021-11-17
host: x86_64-unknown-linux-gnu
release: 1.58.0-nightly
LLVM version: 13.0.0
I would expect rustc
to give a working suggestion here, and definitely not to give a suggestion that is invalid in two distinct ways.
The second issue is also reported by #89220.