Document and test all scopes where #[mutants::skip] applies#1
Closed
sandersaares wants to merge 1 commit into
Closed
Document and test all scopes where #[mutants::skip] applies#1sandersaares wants to merge 1 commit into
sandersaares wants to merge 1 commit into
Conversation
`#[mutants::skip]` has always been honoured at every scope where the
visitor checks attributes — not just on `fn` declarations. The book's
"Skipping functions with an attribute" section, and the surrounding
explanatory text, implied otherwise; the only explicit test coverage of
the attribute was on top-level functions, impl methods, trait default
methods, and modules (via testdata trees), leaving every other supported
scope unexercised.
This commit clarifies the docs and locks in the behaviour with unit
tests for every previously-uncovered scope:
- file inner attribute `#![mutants::skip]`
- `#[mutants::skip] impl Foo { ... }` on the impl block itself
- `#[mutants::skip] trait Foo { ... }` on the trait declaration itself
- expression-level skip on call, method-call, match, struct literal,
and unary expressions
- `#[cfg_attr(test, mutants::skip)]` at non-fn scopes (impl, mod)
Skip on a binary expression is intentionally not tested: syn absorbs
a leading attribute into the leftmost operand, so `ExprBinary.attrs`
is unreachable from any current Rust syntax (same constraint that
applies to `mutants::exclude_re`).
Tests follow the per-file layout already established by the
`exclude_re_expr_*` modules under `src/visit/test/`.
The book's Skip section is rewritten to drop the fn-only framing and
adds a Scope subsection mirroring the one for `exclude_re`.
No behaviour change.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Owner
Author
|
Splitting this up: the exclude_re doc tightening goes into PR sourcefrog#607 (exclude-re-attr) directly; the mutants::skip docs + tests will go in a new independent PR based on main. |
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.
Stacked on top of sourcefrog#607 (�xclude-re-attr).#[mutants::skip] has always been honoured at every scope where the visitor checks attributes — not just on
fndeclarations. The book's Skipping functions with an attribute section implied otherwise, and explicit test coverage of the attribute only exercised top-level functions, impl methods, trait default methods, and modules (via testdata trees), leaving every other supported scope unexercised.This PR locks in the existing behaviour and clarifies the docs. No production code changes.
Tests added
New unit tests under
src/visit/test/for every previously-uncovered scope:#![mutants::skip]— file inner attribute#[mutants::skip] impl Foo { ... }— on the impl block itself#[mutants::skip] trait Foo { ... }— on the trait declaration itself#[cfg_attr(test, mutants::skip)]at non-fn scopes (impl, mod)Skip on a binary expression is intentionally not tested: syn absorbs a leading attribute into the leftmost operand, so
ExprBinary.attrsis unreachable from any current Rust syntax (same constraint that applies tomutants::exclude_re).Tests follow the per-file layout already established by the
exclude_re_expr_*modules.Docs
book/src/attrs.md:functions→items.#[mutants::skip]or nested insidecfg_attr); drop the misleading avoid the dependency sentence.Noteto accurately describe the cfg-condition-not-evaluated behaviour rather than the previous looks for the sequence framing.exclude_resection the same way.exclude_re.