Closed
Description
fn check(constraints: impl Iterator) {
for constraint in constraints {
println!("{:?}", constraint);
}
}
fn main() {}
This yields the error message:
error[E0277]: `<impl Iterator as std::iter::Iterator>::Item` doesn't implement `std::fmt::Debug`
--> src/main.rs:3:26
|
1 | fn check(constraints: impl Iterator) {
| - help: consider further restricting the associated type: `where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug`
2 | for constraint in constraints {
3 | println!("{:?}", constraint);
| ^^^^^^^^^^ `<impl Iterator as std::iter::Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `std::fmt::Debug`
|
= help: the trait `std::fmt::Debug` is not implemented for `<impl Iterator as std::iter::Iterator>::Item`
= note: required by `std::fmt::Debug::fmt`
error: aborting due to previous error
If I add where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug
to the function declaration, I receive:
error[E0667]: `impl Trait` is not allowed in path parameters
--> src/main.rs:2:8
|
2 | where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug
| ^^^^^^^^^^^^^
error[E0562]: `impl Trait` not allowed outside of function and inherent method return types
--> src/main.rs:2:8
|
2 | where <impl Iterator as std::iter::Iterator>::Item: std::fmt::Debug
| ^^^^^^^^^^^^^
error: aborting due to 2 previous errors
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: Suggestions generated by the compiler applied by `cargo fix`Category: This is a bug.Diagnostics: A structured suggestion resulting in incorrect code.Diagnostics: Confusing error or lint; hard to understand for new users.Relevant to the compiler team, which will review and decide on the PR/issue.