Skip to content

Commit 827dbb7

Browse files
committed
Fix infinite recursion in Path::eq with String
1 parent 1d23da6 commit 827dbb7

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

library/std/src/path.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3426,7 +3426,7 @@ impl cmp::PartialEq<Path> for str {
34263426
impl cmp::PartialEq<String> for Path {
34273427
#[inline]
34283428
fn eq(&self, other: &String) -> bool {
3429-
self == &*other
3429+
self == other.as_str()
34303430
}
34313431
}
34323432

library/std/tests/path.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2529,6 +2529,12 @@ fn normalize_lexically() {
25292529

25302530
#[test]
25312531
/// See issue#146183
2532-
fn compare_path_to_str() {
2532+
fn compare_pathbuf_to_str() {
25332533
assert!(&PathBuf::from("x") == "x");
25342534
}
2535+
2536+
#[test]
2537+
/// See issue#146940
2538+
fn compare_path_to_string() {
2539+
assert!(Path::new("x") == &String::from("x"));
2540+
}

0 commit comments

Comments
 (0)