about summary refs log tree commit diff
path: root/src/test/ui/suggestions
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2018-12-16 14:08:25 +0100
committerGitHub <noreply@github.com>2018-12-16 14:08:25 +0100
commitc52a13dcdfb060d6e637ac3557cb8ce8a1600543 (patch)
tree33da61f3563d51322f5402d0e3afb029f66c2eea /src/test/ui/suggestions
parentaf3f9072f541fd9d8da32d981e260df91772fbf8 (diff)
parent33a34b06ac8828ffddc91b822fdec9f862658600 (diff)
downloadrust-c52a13dcdfb060d6e637ac3557cb8ce8a1600543.tar.gz
rust-c52a13dcdfb060d6e637ac3557cb8ce8a1600543.zip
Rollup merge of #56761 - estebank:path-display, r=zackmdavis
Suggest using `.display()` when trying to print a `Path`

Fix #38997.
Diffstat (limited to 'src/test/ui/suggestions')
-rw-r--r--src/test/ui/suggestions/path-display.rs7
-rw-r--r--src/test/ui/suggestions/path-display.stderr14
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/suggestions/path-display.rs b/src/test/ui/suggestions/path-display.rs
new file mode 100644
index 00000000000..62fc9e79f7a
--- /dev/null
+++ b/src/test/ui/suggestions/path-display.rs
@@ -0,0 +1,7 @@
+use std::path::Path;
+
+fn main() {
+    let path = Path::new("/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
new file mode 100644
index 00000000000..39d236af4f3
--- /dev/null
+++ b/src/test/ui/suggestions/path-display.stderr
@@ -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`.