RS.CLIPPY.UNNECESSARY_DEBUG_FORMATTING

`Debug` formatting applied to an `OsStr` or `Path` when `.display()` is available

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: unnecessary_debug_formatting. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Checks for Debug formatting ({:?}) applied to an OsStr or Path.

Why is this bad?

Rust doesn't guarantee what Debug formatting looks like, and it could change in the future. OsStrs and Paths can be Display formatted using their display methods.

Furthermore, with Debug formatting, certain characters are escaped. Thus, a Debug formatted Path is less likely to be clickable.

Example

let path = Path::new("...");
println!("The path is {:?}", path);

Use instead:

let path = Path::new("...");
println!("The path is {}", path.display());