Incorrect `PartialEq` behavior for `UnionFields`
- Dominant language
- Rust
- Stars
- 3.6k
- Forks
- 1.3k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 167
Description
`UnionFields` represents a set of unique field ids paired with unique data types. Internally, it is stored as a list of `(id, data type)` tuples. However, because `UnionFields` currently derives `PartialEq`, equality is determined by the raw tuple list ordering rather than by set semantics
This leads to incorrect behavior, such as the following assertion failing even though the logical sets are identical:
```rs
assert_eq!(
UnionFields::from(&[(0, t1), (1, t2)]),
UnionFields::from(&[(1, t2), (0, t1)])
);
```
Contributor guide
Research direction
Start at the UnionFields entry point and inspect its current derived PartialEq behavior and tuple representation. Add coverage for equality between the two differently ordered examples shown in the issue, and consider the work done when logically identical field-and-type sets compare equal regardless of ordering.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- data
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100