Open
Description
I tried this code:
fn foo(iter: impl IntoIterator<IntoIter = impl Sized>) {
iter.into_iter().next();
}
I expected to see this happen: compiles successfully
Instead, this happened:
error[E0599]: no method named `next` found for type parameter `impl Sized` in the current scope
--> src/lib.rs:2:22
|
1 | fn foo(iter: impl IntoIterator<IntoIter = impl Sized>) {
| ---------- method `next` not found for this type parameter
2 | iter.into_iter().next();
| ^^^^ method not found in `impl Sized`
|
= help: items from traits can only be used if the type parameter is bounded by the trait
help: the following trait defines an item `next`, perhaps you need to restrict type parameter `impl Sized` with it:
|
1 | fn foo(iter: impl IntoIterator<IntoIter = impl Sized + Iterator>) {
| ++++++++++
For more information about this error, try `rustc --explain E0599`.
error: could not compile `scratch` (lib) due to previous error
Meta
rustc --version --verbose
:
rustc 1.76.0-nightly (f5dc2653f 2023-11-25)
binary: rustc
commit-hash: f5dc2653fdd8b5d177b2ccbd84057954340a89fc
commit-date: 2023-11-25
host: x86_64-unknown-linux-gnu
release: 1.76.0-nightly
LLVM version: 17.0.5
@rustbot label A-impl-trait T-types
Activity