Skip to content

Commit

Permalink
Merge pull request #88 from stepancheg/partial-eq-bug
Browse files Browse the repository at this point in the history
Document PartialEq for Arc bug
  • Loading branch information
Manishearth authored Apr 19, 2024
2 parents 81e3602 + dfc9e61 commit 221076c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,7 @@ impl<T: ?Sized> Drop for Arc<T> {

impl<T: ?Sized + PartialEq> PartialEq for Arc<T> {
fn eq(&self, other: &Arc<T>) -> bool {
// TODO: pointer equality is incorrect if `T` is not `Eq`.
Self::ptr_eq(self, other) || *(*self) == *(*other)
}

Expand Down Expand Up @@ -1050,6 +1051,15 @@ mod tests {
assert_eq!(1, Arc::strong_count(&arc2));
}

#[test]
fn test_partial_eq_bug() {
let float = f32::NAN;
assert_ne!(float, float);
let arc = Arc::new(f32::NAN);
// TODO: this is a bug.
assert_eq!(arc, arc);
}

#[allow(dead_code)]
const fn is_partial_ord<T: ?Sized + PartialOrd>() {}

Expand Down

0 comments on commit 221076c

Please sign in to comment.