# Rust E0277: type doesn't implement Debug

> Fix Rust E0277 when a value cannot be formatted with {:?} because its type does not implement std::fmt::Debug.

HTML: https://rustprint.com/errors/doesnt-implement-debug/

Rust reports E0277 when code requires a trait that the type does not implement. With `{:?}` formatting, the required trait is `std::fmt::Debug`.

**A custom struct used with {:?} without a Debug implementation**

```rust
struct Point {
    x: i32,
}

fn main() {
    let point = Point { x: 3 };
    println!("{point:?}");
}
```

The example above is intentionally rejected by the stable Rust compiler in CI.

## Fix your own struct with derive(Debug)

For ordinary structs and enums, deriving `Debug` is usually the simplest fix.

**Derive Debug and format the struct with {:?}**

```rust
#[derive(Debug)]
pub struct DebugPoint {
    pub x: i32,
}
```

The standard library explicitly recommends deriving `Debug` in the general case. The resulting representation is for programmer-facing inspection, not a stable serialization format.

## Generic code may need a Debug bound

E0277 can also appear even when every value you currently pass happens to implement `Debug`. A generic function using `{:?}` must state that requirement in its signature, for example with `T: std::fmt::Debug` or an equivalent `where` clause.

The compiler checks the generic function against all types allowed by its declared bounds. It does not infer a permanent `Debug` requirement merely from the types used at current call sites. This is the same trait-bound rule described by the official E0277 documentation.

## When derive(Debug) is not enough

A derived implementation requires the fields that it formats to support `Debug`. If you need a deliberate programmer-facing representation, or need to control which fields participate, [implement `Debug` manually](/debug/implement-debug/index.md) using the formatter's debug builders.

For normal inspection, see [inspect values with Debug and dbg!](/debug/inspect-values/index.md) and [pretty Debug with `{:#?}`](/debug/pretty-debug/index.md).

If the compiler instead says the type does not implement `Display`, see [E0277: type doesn't implement Display](/errors/doesnt-implement-display/index.md).

## Sources

- [Rust error E0277](https://doc.rust-lang.org/stable/error_codes/E0277.html)
- [std::fmt::Debug](https://doc.rust-lang.org/std/fmt/trait.Debug.html)

## Related RustPrint guides

- [Implement custom Debug in Rust](/debug/implement-debug/index.md): Implement Rust's Debug trait manually with Formatter::debug_struct, choose which fields appear, redact sensitive values, and keep {:#?} pretty printing.
- [Rust dbg! macro: inspect values with Debug](/debug/inspect-values/index.md): Use Rust dbg! to print expressions to stderr, understand its return and move behavior, and compare compact {:?} with pretty {:#?} Debug output.
- [Debug vs Display in Rust](/debug/debug-vs-display/index.md): Choose between Rust Debug and Display based on programmer-facing inspection versus deliberate user-facing text.
- [Rust pretty print a struct with {:#?}](/debug/pretty-debug/index.md): Pretty print Rust structs, enums, maps, and nested values with {:#?}, derive Debug, and understand why Debug output is not a stable serialization format.
