Skip to content

Commit 520343e

Browse files
committed
Add test of Debug and Display of paths
DisplayDebug currently works but DebugDisplay does not. error[E0277]: `PathBuf` doesn't implement `std::fmt::Display` --> tests/test_path.rs:36:13 | 32 | #[derive(Error, Debug)] | ----- in this derive macro expansion ... 36 | #[error("debug:{0:?} display:{0}")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it | = help: the trait `std::fmt::Display` is not implemented for `PathBuf` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data = help: the trait `std::fmt::Display` is implemented for `Var<'_, T>` = note: this error originates in the macro `$crate::format_args` which comes from the expansion of the derive macro `Error` (in Nightly builds, run with -Z macro-backtrace for more info)
1 parent 49be39d commit 520343e

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

tests/test_path.rs

+8
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ pub struct UnsizedError {
2929
pub tail: str,
3030
}
3131

32+
#[derive(Error, Debug)]
33+
pub enum BothError {
34+
#[error("display:{0} debug:{0:?}")]
35+
DisplayDebug(PathBuf),
36+
#[error("debug:{0:?} display:{0}")]
37+
DebugDisplay(PathBuf),
38+
}
39+
3240
fn assert<T: Display>(expected: &str, value: T) {
3341
assert_eq!(expected, value.to_string());
3442
}

0 commit comments

Comments
 (0)