diff --git a/library/std/src/path.rs b/library/std/src/path.rs index 531a1aa421536..19663e4a9df62 100644 --- a/library/std/src/path.rs +++ b/library/std/src/path.rs @@ -2107,7 +2107,7 @@ impl PartialEq for PathBuf { impl cmp::PartialEq for PathBuf { #[inline] fn eq(&self, other: &str) -> bool { - &*self == other + Path::eq(self, other) } } diff --git a/library/std/tests/path.rs b/library/std/tests/path.rs index 3577f0d9c7bb6..fa76c50597b05 100644 --- a/library/std/tests/path.rs +++ b/library/std/tests/path.rs @@ -2526,3 +2526,9 @@ fn normalize_lexically() { check_err(r"\\?\UNC\server\share\a\..\.."); } } + +#[test] +/// See issue#146183 +fn compare_path_to_str() { + assert!(&PathBuf::from("x") == "x"); +}