-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
format!
debug fails even though Debug is implemented
#72197
Comments
I've tried to remove the use std::fmt::{self, Debug};
trait Trait {
type A: Debug;
}
struct S1 {}
impl Trait for S1 {
type A = u64;
}
struct S2<T: Trait> {
a: T::A,
}
impl<T: Trait> Debug for S2<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?}", self)
}
}
fn main() {
let s = S2::<S1> { a: 10 };
format!("{:?}", s);
} However, when I run it, I get:
|
The generated Debug impl expanded is: #[automatically_derived]
#[allow(unused_qualifications)]
impl<T: ::core::fmt::Debug + Trait> ::core::fmt::Debug for S2<T>
where
T::A: ::core::fmt::Debug,
{
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
match *self {
S2 { a: ref __self_0_0 } => {
let mut debug_trait_builder = f.debug_struct("S2");
let _ = debug_trait_builder.field("a", &&(*__self_0_0));
debug_trait_builder.finish()
}
}
}
} Since |
Here you call |
Thanks for pointing it out. Replacing |
I tried this code:
When trying to compile it, I get:
The
[derive(Debug)]
alone seems to work since the program compiles without theformat!
.Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: