What it does
Warn when a Debug representation of Path is used in format! or println!, instead of path.display().
Advantage
Rust doesn't guarantee how Debug formatting looks like, and it could change in the future. For printing paths there's the dedicated .display() method.
Drawbacks
Not every Debug print of a Path is incorrect: it may be used in dbg!(), or when a PathBuf is a field in a struct that is Debug-printed as a whole.
Example
let path = Path::new("…");
println!("The path is {:?}", path);
Could be written as:
let path = Path::new("…");
println!("The path is {}", path.display());
What it does
Warn when a
Debugrepresentation ofPathis used informat!orprintln!, instead ofpath.display().Advantage
Rust doesn't guarantee how
Debugformatting looks like, and it could change in the future. For printing paths there's the dedicated.display()method.Drawbacks
Not every
Debugprint of aPathis incorrect: it may be used indbg!(), or when aPathBufis a field in a struct that isDebug-printed as a whole.Example
Could be written as: