diff options
| author | Michael Goulet <michael@errs.io> | 2022-02-21 16:58:12 -0800 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2022-02-21 16:58:12 -0800 |
| commit | a08809ff7badda201cc98fc20d9340a07567e43a (patch) | |
| tree | c5e55b113acb29262ab9aad3be14a44d370d5311 /src | |
| parent | 03a8cc7df1d65554a4d40825b0490c93ac0f0236 (diff) | |
| download | rust-a08809ff7badda201cc98fc20d9340a07567e43a.tar.gz rust-a08809ff7badda201cc98fc20d9340a07567e43a.zip | |
Suggest calling .display() on PathBuf too
Diffstat (limited to 'src')
| -rw-r--r-- | src/test/ui/suggestions/path-display.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/suggestions/path-display.stderr | 12 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/test/ui/suggestions/path-display.rs b/src/test/ui/suggestions/path-display.rs index 62fc9e79f7a..3a022e6b02f 100644 --- a/src/test/ui/suggestions/path-display.rs +++ b/src/test/ui/suggestions/path-display.rs @@ -1,7 +1,11 @@ -use std::path::Path; +use std::path::{Path, PathBuf}; fn main() { let path = Path::new("/tmp/foo/bar.txt"); println!("{}", path); //~^ ERROR E0277 + + let path = PathBuf::from("/tmp/foo/bar.txt"); + println!("{}", path); + //~^ ERROR E0277 } diff --git a/src/test/ui/suggestions/path-display.stderr b/src/test/ui/suggestions/path-display.stderr index 25c73c4c874..5e718d79307 100644 --- a/src/test/ui/suggestions/path-display.stderr +++ b/src/test/ui/suggestions/path-display.stderr @@ -8,6 +8,16 @@ LL | println!("{}", path); = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0277]: `PathBuf` doesn't implement `std::fmt::Display` + --> $DIR/path-display.rs:9:20 + | +LL | println!("{}", path); + | ^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it + | + = help: the trait `std::fmt::Display` is not implemented for `PathBuf` + = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data + = note: this error originates in the macro `$crate::format_args_nl` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. |
