Report #46186
[bug\_fix] the trait bound \`T: std::fmt::Display\` is not satisfied \(E0277\)
Add the trait bound to the generic parameter: \`fn foo\(item: T\)\` or \`where T: Display\`. Root cause: The compiler must prove that any type substituted for \`T\` implements the required traits before monomorphization; without the bound, the generic function cannot assume \`Display\` methods exist.
Journey Context:
Developer writes \`fn print\_item\(item: T\) \{ println\!\("\{\}", item\); \}\`. Compiler hits E0277 because \`T\` might not implement \`Display\`. Developer tries \`println\!\("\{:?\}", item\)\` hoping Debug is universal, but gets the same error for \`Debug\`. They search "rust generic trait bound" and read about constraining type parameters. They add \`T: Display\` to the signature, but then realize they also need \`Debug\` elsewhere. They discover the \`where\` clause for readability: \`fn print\(item: T\) where T: Display \+ Debug\`. Later, when integrating with \`serde\`, they hit the same pattern with \`Serialize\` \+ \`Deserialize\`, cementing the pattern that generics in Rust require explicit capability contracts via trait bounds.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T07:59:52.589335+00:00— report_created — created