File tree 3 files changed +17
-3
lines changed
3 files changed +17
-3
lines changed Original file line number Diff line number Diff line change @@ -728,7 +728,7 @@ pub use macros::Debug;
728
728
/// ```
729
729
#[ rustc_on_unimplemented(
730
730
on(
731
- _Self = "std::path::Path" ,
731
+ any ( _Self = "std::path::Path" , _Self = "std::path::PathBuf" ) ,
732
732
label = "`{Self}` cannot be formatted with the default formatter; call `.display()` on it" ,
733
733
note = "call `.display()` or `.to_string_lossy()` to safely print paths, \
734
734
as they may contain non-Unicode data"
Original file line number Diff line number Diff line change 1
- use std:: path:: Path ;
1
+ use std:: path:: { Path , PathBuf } ;
2
2
3
3
fn main ( ) {
4
4
let path = Path :: new ( "/tmp/foo/bar.txt" ) ;
5
5
println ! ( "{}" , path) ;
6
6
//~^ ERROR E0277
7
+
8
+ let path = PathBuf :: from ( "/tmp/foo/bar.txt" ) ;
9
+ println ! ( "{}" , path) ;
10
+ //~^ ERROR E0277
7
11
}
Original file line number Diff line number Diff line change @@ -8,6 +8,16 @@ LL | println!("{}", path);
8
8
= note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
9
9
= note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
10
10
11
- error: aborting due to previous error
11
+ error[E0277]: `PathBuf` doesn't implement `std::fmt::Display`
12
+ --> $DIR/path-display.rs:9:20
13
+ |
14
+ LL | println!("{}", path);
15
+ | ^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it
16
+ |
17
+ = help: the trait `std::fmt::Display` is not implemented for `PathBuf`
18
+ = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data
19
+ = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info)
20
+
21
+ error: aborting due to 2 previous errors
12
22
13
23
For more information about this error, try `rustc --explain E0277`.
You can’t perform that action at this time.
0 commit comments