about summary refs log tree commit diff
path: root/library/std/tests
diff options
context:
space:
mode:
authorIris Shi <0.0@owo.li>2025-09-24 12:55:38 +0800
committerIris Shi <0.0@owo.li>2025-09-24 21:30:41 +0800
commit5a4e53603631475335bab3e1416f4aca61172094 (patch)
treefdaeada949338e33b9ec601636126a9f274c183c /library/std/tests
parentae12bc21d8ec76bbb753d4da168e9b08e1b09ebf (diff)
downloadrust-5a4e53603631475335bab3e1416f4aca61172094.tar.gz
rust-5a4e53603631475335bab3e1416f4aca61172094.zip
Fix infinite recursion in Path::eq with String
Diffstat (limited to 'library/std/tests')
-rw-r--r--library/std/tests/path.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/library/std/tests/path.rs b/library/std/tests/path.rs
index fa76c50597b..837a14b808f 100644
--- a/library/std/tests/path.rs
+++ b/library/std/tests/path.rs
@@ -2528,7 +2528,17 @@ fn normalize_lexically() {
 }
 
 #[test]
-/// See issue#146183
-fn compare_path_to_str() {
-    assert!(&PathBuf::from("x") == "x");
+/// See issue#146183 and issue#146940
+fn compare_path_like_to_str_like() {
+    let path_buf = PathBuf::from("x");
+    let path = Path::new("x");
+    let s = String::from("x");
+    assert!(path == "x");
+    assert!("x" == path);
+    assert!(path == &s);
+    assert!(&s == path);
+    assert!(&path_buf == "x");
+    assert!("x" == &path_buf);
+    assert!(path_buf == s);
+    assert!(s == path_buf);
 }