-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages f
8481
or errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
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
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.