Open
Description
Hello,
I'm guessing there "might" be something wrong how the Debug
trait is derived in case a type is owned but not actually needed for formatting the object. The following code fails because B
is not necessarily Debug
which is correct, however since Foo
doesn't actually have an instance of B
as a field, that shouldn't be needed, and B::Item
is restricted to Debug
:
#[derive(Debug)]
struct Foo<B: Bar>(B::Item);
trait Bar {
type Item: Debug;
}
fn foo<B: Bar>(f: Foo<B>) {
println!("{:?}", f);
}
struct ABC();
impl Bar for ABC {
type Item = String;
}
fn main() {
foo(Foo::<ABC>("a".into()));
}
error[E0277]: `B` doesn't implement `std::fmt::Debug`
--> src/main.rs:65:22
|
65 | println!("{:?}", f);
| ^ `B` cannot be formatted using `:?` because it doesn't implement `std::fmt::Debug`
|
= help: the trait `std::fmt::Debug` is not implemented for `B`
= help: consider adding a `where B: std::fmt::Debug` bound
= note: required because of the requirements on the impl of `std::fmt::Debug` for `middlewares::authentication::Foo<B>`
= note: required by `std::fmt::Debug::fmt