Mutate NonZero<T> generic return types#602
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds mutation-generation support for Rust’s generic std::num::NonZero<T> return types (in addition to the existing NonZeroU32, NonZeroIsize, etc. matching), plus accompanying unit tests. Also updates release metadata to 27.0.0.
Changes:
- Extend
type_replacementsto recognizeNonZero<T>and generate appropriate non-zero integer candidates based on whetherTis signed/unsigned/unknown. - Add unit tests covering unsigned, signed, and unknown generic
NonZero<T>cases. - Bump crate version and update changelog/release metadata for 27.0.0.
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
src/fnvalue.rs |
Adds NonZero<T> detection and new tests validating generated replacement expressions. |
NEWS.md |
Updates top-of-file release section to 27.0.0 with a release date. |
Cargo.toml |
Bumps package version from 27.0.0-pre to 27.0.0. |
Cargo.lock |
Updates the lockfile entry to reflect the new package version. |
Comments suppressed due to low confidence (1)
NEWS.md:9
- The 27.0.0 changelog entry doesn’t mention the new
NonZero<T>mutation support added in this PR. Consider adding a bullet (e.g., New/Fixed) describing the genericNonZero<T>return-type replacements so the release notes reflect the user-visible change.
## 27.0.0
Released 2026-03-07.
- Changed: Command line values for `--file`, `--exclude`, `--examine-re`, and `--exclude-re` are now combined with, rather than replacing, values given in the configuration file, consistently with every other option that takes a list. (Use `--config=OTHER` or `--no-config` to avoid using values in the configuration.) Thanks to @sandersaares for pointing this out.
- New: `--Zmutate-file` lists the mutants generated from a single Rust source file in text or JSON, without reading or requiring a containing package. This is intended as an aid for developing and debugging mutation patterns.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Contributor
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Support the generic NonZero<T> form (stabilized in Rust 1.79) in addition to the existing NonZeroUsize, NonZeroI32, etc. type-specific matching. When T is a known unsigned type, generate 1; when signed, generate 1 and -1; when unknown, assume signed. Closes #595 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
NonZero<T>form (stabilized in Rust 1.79) in addition to the existingNonZeroUsize,NonZeroI32, etc. type-specific matchingTis a known unsigned type, generate1; when signed, generate1and-1; whenTis unknown, assume it could be signed and generate bothCloses #595
Test plan
NonZero<u32>,NonZero<usize>,std::num::NonZero<u8>(unsigned)NonZero<i32>,NonZero<isize>,std::num::NonZero<i64>(signed)NonZero<T>with unknown type parameter🤖 Generated with Claude Code