From f19da67ed75468a2cb90572c065d1c3e2a8cadec Mon Sep 17 00:00:00 2001 From: bendn Date: Thu, 4 Sep 2025 14:06:31 +0700 Subject: [PATCH 1/2] add test --- library/std/tests/path.rs | 6 ++++++ 1 file changed, 6 insertions(+) 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"); +} From 1e37c1fe2e29d88d4843e7c0ce46e50edd9f7251 Mon Sep 17 00:00:00 2001 From: bendn Date: Thu, 4 Sep 2025 14:06:44 +0700 Subject: [PATCH 2/2] fix --- library/std/src/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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) } }