An assignment that ends a block without a semicolon (`{ input = c }`) now
makes its alias at the block's close instead of after the next statement.
A `let` inside a move closure, or one of its parameters, now counts as a
local binding: an assignment to it ends the alias as it does outside a
closure. Assignments to outer captures are still skipped.
A closure stored with `let` in `Some`, `Ok`, `Err`, `Box::new`, `Rc::new`
or `Arc::new` and never used again does not run, so its assignments no
longer end an alias. A closure passed to any other call may run and still
ends it.
An async closure called where it is written now runs when the call is
passed straight to `block_on` (a trailing comma included), unless the
`block_on` sits inside another closure.
all-unguarded, only-weak, exit-status-only, no-assertion, early-return,
env-gate-unset, census, mirror, constant-echo, fixture-only and
exact-pixel only listed their hits before. Their hits on changed lines
and tests now fail the check like the other rules. A
`// test-lint: allow <rule> <reason>` comment still exempts a hit, and
hits on unchanged lines still do not fail.
A never-run test that builds on macOS or Windows is still listed
without failing, since it runs locally on that platform.
Docs: docs/development.md.
The census rule leaves out a loop that feeds each entry into a
computation. It now checks that the computation runs, and that it runs
on the entry:
- An alias assigned another value no longer holds the entry, and one
assigned the entry holds it. Assignments in an empty loop, an async
block, a move closure or a closure the loop never calls do not change
the alias, and one that may be skipped does not make one.
- A nested for body counts only when its source is a literal range or
array that is not empty.
- A block in an earlier argument keeps the enclosing || or && that can
skip the call.
- Calling an async closure counts only when the future is awaited or
passed to block_on.
- A closure that is not bound with let counts only when it is called
where it is written; a parenthesized initializer binds the closure.
- A closure call resolves to the binding in scope at the call, so a
later let of the same name takes it.
- A conjunction inside a parenthesized operand of an asserted && is
required, unless an || at its level can bypass it.
With test selection, a pull request that moves a crate between shards in
GROUPS without changing ci.yml could skip the shard holding the test
that compared the two. `shards::check`, which every shard and warm leg
runs, now compares them and fails with both lists.
A path string that continues on the next line with a backslash now
decodes to the joined file name, so the conditional route is kept.
A range argument with two fixed bounds (1..4, 1..=4) no longer counts
as an input, so the round-trip census diagnostic stays; a range with a
variable bound still suppresses it. Adds a test for a bracket in a
cfg_attr path filename keeping its sibling cfg gate.
- An entry name after `::` (`defaults::c`) is a path segment, not a read of the loop binding.
- A `let` initializer scans to the end of its statement, so a block initializer binds its tail
(`{ prepare(); c }`) and not the earlier statements in the block; `if let` and `while let`
end at their block.
- A call keeps its name when masked comment whitespace sits before `(`, except after a keyword
(`if (a)`).
- The argument-guard and alias tests now depend on the logic they cover.
- A renamed import (`use super::other::near as comparison;`) no longer
counts as a call with a path; an import that keeps the name still does.
- A bare call to a helper's name checks for a local binding in scope
(`let near = || {}; near();`), skipping type annotations, field labels
and path segments in patterns.
- Helpers passed in assertion failure messages no longer count as checks.
- A match-arm binding covers the arm's guard, and the arm's pattern stops
at the block of the arm before it.
- `#[ ignore = "..."]` with whitespace is read as an ignore attribute,
both for diagnostic tests and for ignore-without-reason.
- Literal ranges read `0x`, `0o` and `0b` bounds.
- A pin compares literal arguments (`r.items("active")` against
`r.items("archived")`), and does not count when a clone or borrow of the
source made before the snapshot is still alive.
- A function parameter named like a constant table is not the table.
The changed-lines mode read each base file with `git show` and only then
compared the length of the trimmed, lossily decoded text with the 16 MiB
limit, so a large blob was loaded in full before it was skipped, and
trailing whitespace and invalid UTF-8 changed the length it was judged
by. The base reads now take each blob's size from one `git ls-tree -l`
listing of `crates`, `apps` and `xtask` (or `git cat-file -s` for a path
the listing does not hold) and run `git show` only for blobs within the
limit.
A plain #[path = "\x63hild.rs"] after #[cfg_attr(windows, path = "child.rs")]
loads child.rs on Linux and FreeBSD, but test-lint compared the undecoded
spelling with the file name, dropped that route and reported a test in
child.rs as never-run. The plain attribute and the path argument of
cfg_attr now decode the escapes of an ordinary string literal with the
same unescape the cfg values use. Raw string literals are read as written.
An expression closure such as `|body: fn()| forward::<u8, u16>(body)`
ended at the comma inside the turbofish, so a parameter named like an
asserting helper stopped shadowing it at that comma. The closure body
now skips a turbofish whole.
A count or emptiness getter on a pinned snapshot (`let _ = got.len();`)
keeps the pin; only a read of the receiver itself that is bound or
passed to a call may hand out an alias.
no-assertion:
- A call in a top-level test reaches the helper its own file defines. A
non-asserting helper of the same name in another file of the crate no
longer hides it. Names the file also calls with a path, and
definitions below the file's top level, keep the crate's verdict.
- An `#[ignore = "reason"]` test that prints is a diagnostic and needs
no assertion.
- An asserting function passed by name as a value
(`keeping_settings(the_body)`, `run(&[body])`) counts as the test's
check, also through a helper that passes it, unless a local binding,
loop pattern, match arm or parameter shadows the name in scope, or the
value is dropped (`drop(body)`, `let _ = Some(body)`, `(body,);`).
all-unguarded:
- A parenthesized range of literals or constants, `(0..3).all(...)`.
- A receiver whose source an earlier `assert_eq!` compares with a
non-empty literal: a local collected from the receiver, or the call
the receiver is bound to, when nothing changes the source in between.
A shared borrow passed to a call outside an assertion may change it.
- A call to a function of the file that lists every row of a non-empty
constant table without filtering it; every function of that name in
the file has to do so.
A loop over a whole table whose body passes the entry to a call together
with other state (a command run, a file written, a render, a parse of
other input) checks behavior for each entry, so the census rule no
longer reports it. A lookup, a call on the entry alone, literal
arguments and calls in a failure message still count as a census.
The call counts only where it runs whenever the loop's assertions pass:
not after an `||`, not on the right of an `&&` whose result is not
asserted, not inside an `if`, `else`, `match` arm, `while` or async
body, and not inside a closure the loop never calls. A name counts as
the entry from the `let` that binds it from the entry to the end of its
block, and not where a nested loop, a closure parameter or another
`let` rebinds it or where it names a field. An asserting helper keeps a
loop out of the census only where it runs the same way, and a round trip
can read the entry as its receiver (`k.parse()`).
- never-run: in changed mode, a file that a crate target loaded at the
base and no target loads now counts as compiled out, so removing the
last `mod` or `#[path]` declaration on the way to it, or deleting the
only target root that loads it, fails the check for its tests.
- reads-source: an `ends_with(".rs")` check counts only when it picks
entries from a file listing (an iterator filter or a `for` loop over
one), or when the function around it reads a file or calls a function
in the file that does. A suffix check on a generated name in a test
that reads nothing is not reported.
- census: a helper on the left of an `||` hides the whole-table check on
the right only when it always runs: not behind an `&&`, and not inside
one arm of an `if` or `match`.
- docs: unchanged-line `never-run` hits fail the command when the change
takes away a test's last CI route.
main replaced the hit's per-file `also` ranges with `gates`, a list of
lines in the hit's own file. The sleep rule's loop and spawn spans now
add their lines to `gates`. The `last_literal` and `path_literal`
helpers that main replaced are left out.
craft-libs #4659 (swatch chips that fit a one-column rail) and #4723
have merged, so every craft-libs rev moves from #4659's head edbf2117
to craft-libs main at 77ade517. The egui revisions move to 861d60a6,
the ones that craft-libs rev pins; winit stays at 0dfcec0e. Cargo.lock
changes only the sources of those packages.
never-run failed the check on tests of macOS- or Windows-only code, such
as the touchpad gesture tests in quickpenwheel.rs and the Windows
performance counter tests in vectorcraft-cli's perf.rs. CI cannot build
them on Linux, and they run locally on their platform.
A never-run hit on a test that still builds on macOS (aarch64 or x86_64)
or Windows (x86_64 or aarch64) is now listed with the report-only rules,
and its note says which platform to run it on. A test that no desktop
target builds, such as one gated on target_os = "ios" or
all(windows, unix), still fails the check.
- A spawned sleep is exempt only when the closure is the direct argument
of `spawn`, not of a call inside it such as `spawn(prepare(|| …))`.
- A bare `spawn` or `sleep`, and a `thread::` path, count only where a
`use` brings them in from `std::thread`; `crate::thread::spawn` and
`std::thread::{self as worker}` do not.
- A sleep hit inside a spawned closure spans through the end of the
spawn statement, so an edit that adds `.join()` there counts as a
change. The brace-less `spawn(|| thread::sleep(D))` form gets the
same span.
- A block operand after a spaced `<` or `>` stays in the loop condition.
- `while n < bound` with `n = n + 1` or `n = n - 1` in the body is a
counted loop, like `n += 1`.
- Calls inside the arguments of `println!`, `eprintln!` and the log
macros are not polling work.
- A `while n < bound` loop that adds to or subtracts from `n` in its body
counts its own passes, so calls in the bound (`attempts.len()`) no
longer exempt the sleep. A condition that also has `&&` or `||` keeps
its calls as polling evidence.
- A change to the loop or spawn closure around a reported sleep counts as
a change to the hit, so an edit that removes the poll from the
condition fails the changed-line check.
- `use std::thread::spawn as spawn_thread;` and
`use std::thread::sleep as nap;` no longer bring in the bare names, and
`thread::sleep_ms` no longer matches `thread::sleep`.
- A `thread::spawn` path counts only where a `use` binds `thread` to
`std::thread`, so a local `mod thread` with its own `spawn` is not
exempt.
- A `;` inside a nested block in a loop condition
(`while !ready({ let key = 1; key })`) no longer ends the header, and a
block after `||` stays part of the condition.
- A sleep in a `let` initializer block inside a dropped spawn closure is
exempt like the closure's other sleeps; the same block inside a polling
loop is still reported.
- A dropped-handle spawn counts only as `thread::spawn` through a path,
with or without a leading `::`, or as a bare `spawn` that a `use` brings
in. A local `fn spawn` that runs the closure at once is reported.
- A sleep that is the whole body of a closure without braces is judged by
the call that takes the closure: a dropped `thread::spawn` is exempt, and
a joined one is reported even inside a polling loop.
- A `loop` used as a `let` value is checked for polling calls.
- Calls inside the sleep's own argument and inside `stringify!` are not
polling work, and neither are `unwrap`, `expect` and the `unwrap_or`
family.
- `Duration::new` is matched per call, with `Duration` as a whole path
segment, so a local named `new` or `ScheduleDuration::new()` does not
change the result.
- Changed mode builds the base's target-root routes from the base tree,
so a deleted tests/<root>.rs still counts as loading tests/common/mod.rs.
- A base test is matched by its name, its inline modules and its place
among same-named tests in them, so removing `mod a` does not let
`a::t` hide a newly off `b::t`.
- reads-source looks through grouping around the read path and names a
file only from a complete literal, a format!/concat! call or
Path::new/PathBuf::from; `"data.json".trim_end_matches(".rs")` no
longer counts as a .rs file.
- mirror keys keep a raw literal whole up to its own delimiter, and a
key must be one complete string literal.
- for, if let, while let, let and match patterns keep word boundaries
(`mut n` binds `n`), and a struct pattern's braces are not taken as
the loop or if-let body.
- #[path] and cfg_attr path values accept raw string literals.
- never-run in changed mode lints the file as it was at the base and
matches a test by its name and its place among tests of that name, so
a test that was already off is not counted again when lines move.
- A file reached by name inherits only the gates of named declarations,
and one reached through #[path] only those of #[path] declarations.
- The changed-file walk also reads the base child declarations of a
#[path]-loaded file, so a removed `mod child;` still reaches the child.
- reads-source classifies the outer path step, not a join nested in its
argument.
- mirror treats complete raw string literals as keys.
- A raw cfg value keeps the quotes inside it (r#""unix""# is not unix).
- census keeps word boundaries, so `k as usize` reads `k` and the local
`kasusize` does not.
- fixture-only finds a for loop's `in` across line breaks.
The poll check now:
- keeps a block condition (`while { r.load(SeqCst) } { ... }`) in the
loop header, so the loop counts as a poll, while a `m! { ... }` macro
before a loop still ends the statement before it;
- strips a loop label (`'outer: while ...`) before looking for the
keyword;
- treats `move || -> () { ... }` as a spawned closure, like `move || {`;
- does not take `return ::std::thread::spawn(...);` as a dropped handle,
since a keyword is not a path segment;
- does not count a nested `fn` item's name as a call in the loop.
main's test-lint changes rewrote the same functions as this branch
(module_parent, never_run, cfgs_over, reads_source_hits, names_rect).
The resolution keeps this branch's module routing (Gates, #[path]
overrides, base comparison) and takes from main: the 64-level bound in
weak_predicate, `&` before a lookup as a derived value, skipping later
attributes such as #[test_case(1; "one")] when finding a cfg's item,
and leaving out the lines of a cfg that holds on every CI target.
The review fixes for the same functions are part of the resolution:
- reads-source classifies by the final path step, so a final
.with_extension("json") is not a .rs read and .with_extension(ext)
is an unknown file.
- fixture-only reads a closure parameter as a new binding inside the
closure body.
- cfg argument lists split on commas outside string literals, in
cfg(any/all), cfg_attr predicates and cfg_attr paths.
- tests/<dir>/mod.rs takes its gates from the target roots beside it
that declare it, so a helper that only a macOS-gated mod declaration
loads is reported.
- a file loaded through #[path] declares its modules in its own
directory (impl/platform.rs loads impl/child.rs), and a change to it
reaches those files.
- a #[cfg_attr(<cond>, path = "...")] on an inline module is a
conditional route, with the default directory where the condition
does not hold.
- exact-pixel does not report a rect passed to a call
(count_items(button_rect)).
- each file's cfg attributes are read once instead of once per test.