Commit d9cc669
authored
Remove ^= as mutation for |= and &= operators (#556)
## Problem
When mutating bitwise assignment operators, cargo-mutants was suggesting
replacing `|=` with `^=` (and `&=` with `^=`). However, this mutation is
uninformative for the common pattern of accumulating bits into a bitmap
that starts from zero:
```rust
let base_ix = self.text.len();
self.chars |= slice.chars << base_ix;
self.chars_utf16 |= slice.chars_utf16 << base_ix;
```
In this code (from Zed's `crates/rope/src/chunk.rs`), when accumulating
new set bits into a bitmap that's initially zeros, `|=` and `^=` produce
identical results. The mutation doesn't actually test anything
different.
## Solution
Changed the mutation patterns for bitwise assignment operators:
- `&=` now only mutates to `|=` (removed `^=`)
- `|=` now only mutates to `&=` (removed `^=`)
- `^=` still mutates to both `|=` and `&=` (unchanged)
This makes the mutations more meaningful by ensuring they actually
change the behavior in typical usage patterns.
## Changes
- Updated mutation logic in `src/visit.rs`
- Updated documentation in `book/src/mutants.md` with explicit entries
for bitwise assignment operators
- Added changelog entry to `NEWS.md`
- Updated test expectations in `mutate_assign_ops` test3 files changed
+12
-11
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
| 12 | + | |
11 | 13 | | |
12 | 14 | | |
13 | 15 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
83 | 83 | | |
84 | 84 | | |
85 | 85 | | |
86 | | - | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
87 | 90 | | |
88 | 91 | | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
| 95 | + | |
| 96 | + | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
594 | | - | |
| 594 | + | |
595 | 595 | | |
596 | | - | |
| 596 | + | |
597 | 597 | | |
598 | 598 | | |
599 | 599 | | |
| |||
1389 | 1389 | | |
1390 | 1390 | | |
1391 | 1391 | | |
1392 | | - | |
1393 | | - | |
1394 | | - | |
1395 | | - | |
1396 | | - | |
1397 | | - | |
1398 | | - | |
1399 | | - | |
| 1392 | + | |
| 1393 | + | |
1400 | 1394 | | |
1401 | 1395 | | |
1402 | 1396 | | |
| |||
0 commit comments