forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#56761 - estebank:path-display, r=zackmdavis
Suggest using `.display()` when trying to print a `Path` Fix rust-lang#38997.
- Loading branch information
Showing
3 changed files
with
28 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
use std::path::Path; | ||
|
||
fn main() { | ||
let path = Path::new("/tmp/foo/bar.txt"); | ||
println!("{}", path); | ||
//~^ ERROR E0277 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
error[E0277]: `std::path::Path` doesn't implement `std::fmt::Display` | ||
--> $DIR/path-display.rs:5:20 | ||
| | ||
LL | println!("{}", path); | ||
| ^^^^ `std::path::Path` cannot be formatted with the default formatter; call `.display()` on it | ||
| | ||
= help: the trait `std::fmt::Display` is not implemented for `std::path::Path` | ||
= note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data | ||
= note: required because of the requirements on the impl of `std::fmt::Display` for `&std::path::Path` | ||
= note: required by `std::fmt::Display::fmt` | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0277`. |