File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -609,10 +609,15 @@ pub trait Debug {
609609/// println!("The origin is: {}", origin);
610610/// ```
611611#[ rustc_on_unimplemented(
612+ on(
613+ _Self="std::path::Path" ,
614+ label="`{Self}` cannot be formatted with the default formatter, call `.display()` on it" ,
615+ note="you need to call `.display()` or `.to_string_lossy()` for safely printing paths as \
616+ they may contain non-Unicode data"
617+ ) ,
612618 message="`{Self}` doesn't implement `{Display}`" ,
613619 label="`{Self}` cannot be formatted with the default formatter" ,
614- note="in format strings you may be able to use `{{:?}}` \
615- (or {{:#?}} for pretty-print) instead",
620+ note="in format strings you may be able to use `{{:?}}` (or {{:#?}} for pretty-print) instead" ,
616621) ]
617622#[ doc( alias = "{}" ) ]
618623#[ stable( feature = "rust1" , since = "1.0.0" ) ]
Original file line number Diff line number Diff line change 1+ use std:: path:: Path ;
2+
3+ fn main ( ) {
4+ let path = Path :: new ( "/tmp/foo/bar.txt" ) ;
5+ println ! ( "{}" , path) ;
6+ //~^ ERROR E0277
7+ }
Original file line number Diff line number Diff line change 1+ error[E0277]: `std::path::Path` doesn't implement `std::fmt::Display`
2+ --> $DIR/path-display.rs:5:20
3+ |
4+ LL | println!("{}", path);
5+ | ^^^^ `std::path::Path` cannot be formatted with the default formatter, call `.display()` on it
6+ |
7+ = help: the trait `std::fmt::Display` is not implemented for `std::path::Path`
8+ = note: you need to call `.display()` or `.to_string_lossy()` for safely printing paths as they may contain non-Unicode data
9+ = note: required because of the requirements on the impl of `std::fmt::Display` for `&std::path::Path`
10+ = note: required by `std::fmt::Display::fmt`
11+
12+ error: aborting due to previous error
13+
14+ For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments