Commit Graph
268 Commits
Author SHA1 Message Date
dotCooCoo 4e2581f63d Doc tests: treat cfg_attr lints by what they could do, and skip raw C strings
The check did not read lint attributes inside cfg_attr at all, and it
does not evaluate cfg conditions. Two roots passed although the
condition all() is always true:

- #![cfg_attr(all(), forbid(unsafe_code))] with doc-test deny: the
  library forbids unsafe code, so its doc tests need forbid.
- #![doc(test(attr(deny(unsafe_code), cfg_attr(all(), allow(unsafe_code)))))]:
  the allow lowers the deny.

A cfg_attr now counts only in the direction that is never too lenient:
a forbid inside one asks the doc tests for forbid, and an allow, warn
or expect inside one lowers the doc tests' level. A deny or forbid
inside cfg_attr in the doc-test list still does not count.

The comment and literal scanner also skips raw C strings (cr"..."), so
text such as #![forbid(unsafe_code)] inside one is not read as an
attribute. Tests cover each case.
2026-12-03 21:17:30 -08:00
dotCooCoo fb0bce30e6 Doc tests: read the unsafe-code level that the doc-test attributes leave in force
The check accepted a library root when deny(unsafe_code) or
forbid(unsafe_code) appeared anywhere inside #![doc(test(...))]. Two
roots passed although their doc tests still allow unsafe code:

- #![doc(test(attr(cfg_attr(any(), forbid(unsafe_code)))))]: the lint
  sits inside a cfg_attr whose condition is false, so rustdoc adds no
  lint to the doc tests.
- #![doc(test(attr(deny(unsafe_code), allow(unsafe_code))))]: rustdoc
  adds both attributes in order, and the later allow overrides the deny.

The check now reads only the lint attributes that are direct members of
attr(...), in order, and keeps the last level for unsafe_code. A later
allow, warn or expect lowers deny, and nothing lowers forbid. Tests
cover each case.
2026-12-03 20:06:43 -08:00
dotCooCoo 20a5b6eb50 Merge main into fix/doc-tests-unsafe-code 2026-12-03 19:53:53 -08:00
dotCooCoo 8387f54b97 Doc tests: count only crate-level attributes in the unsafe-code check
The check read every #![...] attribute in a library root, including
ones inside a module's braces. A root with
mod tests { #![doc(test(attr(deny(unsafe_code))))] } and no crate-level
attribute passed, although an attribute inside a module does not apply
to the crate's other doc tests. A #![forbid(unsafe_code)] inside a
module was also read as the library forbidding unsafe code.

Attributes inside braces are now skipped, with a test for each case.
2026-12-03 12:05:15 -08:00
dotCooCoo ebafe0b102 xtask: test-lint normalizes only the current callee path
inert() passed the whole operand before a call to without_turbofish, so an
assertion with many Box::new elements copied every earlier element again at
each call. It now tracks where the current path starts and normalizes only
that path. A test covers a builder path that follows other elements.
2026-12-03 11:58:36 -08:00
dotCooCoo a520deb991 Doc tests: assert the exact report in the unsafe-code check's tests
CI's test-lint step failed with only-weak at xtask/src/doc_tests.rs:250:
every assertion in comments_other_lints_and_allow_do_not_count checked
only that problem() returned Some. Such a test still passes when the
check reports the wrong problem, for example when a commented-out
#![forbid(unsafe_code)] is counted and the forbid message is returned
instead of the deny message.

The tests now compare problem() with the exact message for each case,
and two cases cover a commented-out forbid on either side. The other
tests in the file that checked only is_some, is_none or a substring
compare the full result too.
2026-12-03 11:55:35 -08:00
dotCooCoo b209455e12 xtask: test-lint reads through turbofish arguments in constant-echo and fixture-only
The inert-operand check matched builder paths against the raw text, so
`Vec::<Amount>::new()` was taken for a call of code under test and
`assert_eq!(Vec::<Amount>::new(), EXPECTED)` was not reported as a
constant echo. Names inside the turbofish, such as the `_` in
`Ok::<_, String>(1)`, were also read as locals.

The check now skips `::<...>` arguments and decides whether a name is
called from the token after them. Builder paths are compared with the
turbofish removed. A generic function or method called with a turbofish
(`parse::<u8>("1")`, `s.parse::<u8>()`) now counts as a call, so it no
longer makes a test look like a constant echo or a fixture-only check.
2026-12-03 10:47:13 -08:00
dotCooCoo e6ca6ed1a9 Doc tests: read whole attributes and skip comments in the unsafe-code check
The check read crate-root attributes one physical line at a time and
compared whole attribute strings. It accepted a doc-test attribute that
sat inside a block comment or a string literal, rejected a valid
attribute split over several lines, and did not see `unsafe_code` in a
grouped list such as `#![forbid(unsafe_code, unused_must_use)]`, so it
accepted `deny` in the doc tests of such a library.

The check now removes comments and literal contents, reads each
`#![...]` attribute up to its matching bracket, and reads lint lists
item by item, in the library's own attribute and in the doc-test one.
2026-12-03 10:20:43 -08:00
dotCooCoo 9c11c47f75 Doc tests: unsafe code is denied in doc tests too
Rustdoc builds each doc test as its own crate, without the workspace's
`unsafe_code = "deny"` and without a library's `#![forbid(unsafe_code)]`,
so a doc test holding an `unsafe` block passed `cargo test --doc`.

- Every library root now carries `#![doc(test(attr(forbid(unsafe_code))))]`,
  or `deny` in cad, eps and metafile, which rely on the workspace lint.
- `cargo xtask layers` reports a library whose doc tests are missing the
  attribute, or use `deny` where the library forbids unsafe code.
- AGENTS.md names the rule next to the `unsafe` allowlist.
2026-12-03 09:51:28 -08:00
BFlat 9daf4163eb Merge pull request #10568 from ruchirguitar/fix/web-served-fonts
Web: the site publishes the interface's served fonts under fonts/ui/
2026-12-03 23:14:15 +07:00
.CooCoo b9c37e2586 Merge pull request #10606 from dotCooCoo/fix/census-lint-labels-and-closure-names
xtask: test-lint census rule reads loop labels, radix bounds and closure names
2026-12-03 07:28:56 -08:00
ruchirguitar e2e4b3b917 xtask: web-fonts writes its scratch table in a private tempfile folder 2026-12-03 14:25:33 +05:30
dotCooCoo 0b40292b5a xtask: census rule reads loops and continues used as expressions
The nested-loop scan now strips an initializer, a return or break
operand, and grouping parentheses before the loop keyword, so a
labeled continue inside `let _ = for _ in 0..0 { ... };` is known to
never run, and a continue inside a grouped nested loop targets that
loop. A continue after `=`, `(`, `,`, `return` or `break` now starts
an expression, so `let _: () = continue;` before the call is seen as
skipping it. Macro tokens and `r#continue` stay excluded.
2026-12-02 19:36:11 -08:00
dotCooCoo f83b121a46 xtask: census rule ignores a continue in a nested loop that never runs
A labeled continue inside a nested `for` over a literal source that
yields nothing (`for _ in 0..0`) never executes, so it does not skip the
rest of the outer iteration, and the command call after that loop always
runs. A nested loop that runs (`0..1`) still makes the continue skip the
call.
2026-12-02 18:11:49 -08:00
dotCooCoo af8405e4b0 xtask: census rule counts a continue at the start of a loop body
A continue that opens the loop body had no byte before it, so the
expression-start check failed and the call after it was treated as run.
It now counts. A continue inside the tokens of a macro that does not run
them (stringify!({ continue; })) no longer counts as skipping the call;
one inside a macro that may run its arguments (vec![{ continue; }])
still does.
2026-12-02 16:15:27 -08:00
dotCooCoo e324706fae xtask: census rule reads continue before a call and grouped inline block_on closures
A call in a nested for body no longer counts as run when an earlier
continue that targets that loop can skip it. A continue inside a nested
loop, one whose label names a nearer loop, and a continue token inside a
macro or a raw identifier do not skip the call.

An inline async closure call wrapped in grouping parentheses and passed
as block_on's whole argument (block_on(((async || app.run(c))()))) now
counts as run; a callee that only ends in block_on still does not.
2026-12-02 15:16:57 -08:00
dotCooCoo 38f198bb22 xtask: test-lint census rule reads let( bindings, non-ASCII labels and grouped block_on futures
- A `let` followed directly by `(`, `[` or `&` (`let(_run) = || { ... };`)
  now binds the closure, and Unicode whitespace after `let` separates the
  pattern.
- A loop label with non-ASCII letters (`'été: for _ in 0..0`) is stripped,
  so an empty range still skips the body.
- `block_on((run()))` counts the future as run: grouping parentheses
  around it are skipped. A callee whose name only ends in `block_on`
  (`déblock_on`) still does not count, and Unicode whitespace before
  `block_on` does not join it to the name before.
2026-12-02 12:55:32 -08:00
dotCooCoo 8cea13d8a4 xtask: test-lint census rule reads a loop label with a space before its colon
Rust allows whitespace between a loop label and its colon ('inner : for), so the label is stripped from the loop head in that form too.
2026-12-02 11:57:17 -08:00
dotCooCoo 2e1b575fdc xtask: test-lint census rule reads loop labels, radix bounds and closure names
Follow-up to #10585. The census rule now:

- treats a labeled `for` (`'inner: for _ in 0..0`) like an unlabeled one
  when deciding whether its body runs;
- reads hex, octal and binary range bounds (`0x0..0x1`) and borrowed or
  parenthesized array literals (`&[1]`, `(&[1])`) as loop sources;
- does not count a path call (`other::run()`) as a call to a local closure;
- counts an async closure's future as run by `block_on` only when it is
  the whole argument of `block_on` itself, not of `discard_block_on` or of
  a longer expression, and allows a space before the parenthesis;
- finds the `let` keyword without splitting a name such as `inlet_fn`;
- accepts a trailing comma after a closure stored in `Some(…)`.
2026-12-02 11:09:12 -08:00
ruchirguitar a1ef841a71 xtask: web-fonts creates its own scratch folder and the publish test covers a demand face 2026-12-03 00:21:31 +05:30
dotCooCoo 9106f122bd Merge main into fix/ci-select-tests 2026-12-02 10:20:03 -08:00
.CooCoo 2be104c287 Merge pull request #10553 from dotCooCoo/fix/test-lint-base-size-first
xtask: test-lint checks a base file's blob size before reading it
2026-12-02 09:51:29 -08:00
.CooCoo c45fd2d457 Merge pull request #10585 from dotCooCoo/fix/census-lint-review-points
xtask: test-lint census rule counts a computation only where it runs on the entry
2026-12-02 09:51:23 -08:00
dotCooCoo 722e35895b Merge main into fix/test-lint-helper-ignore-wrapper-guards 2026-12-02 08:25:10 -08:00
dotCooCoo a62b477090 Merge main into fix/census-lint-review-points 2026-12-02 08:19:51 -08:00
dotCooCoo 5594da577b xtask: test-lint census rule ends tail assignments at their block and tells closure locals from captures
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.
2026-12-02 08:17:39 -08:00
.CooCoo 766d1cece8 Merge pull request #10591 from dotCooCoo/fix/test-lint-all-rules-fail
xtask: test-lint fails on a hit of any rule in the changed lines
2026-12-02 08:17:26 -08:00
dotCooCoo 12355cb529 xtask: test-lint fails on a hit of any rule in the changed lines
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.
2026-12-02 07:42:17 -08:00
dotCooCoo aee21d8bb7 Merge main into fix/ci-select-tests 2026-12-02 07:27:01 -08:00
dotCooCoo 959af106ba Merge main into fix/ci-select-tests 2026-12-02 07:25:30 -08:00
dotCooCoo 8fd6ba499e Merge main into fix/rebalance-test-shards 2026-12-02 07:24:39 -08:00
.CooCoo d4fbb1402e Merge pull request #10260 from dotCooCoo/fix/plugins-tree-audit-in-checks
CI: the plug-in grant call-site audit runs in the checks shard
2026-12-02 07:13:43 -08:00
dotCooCoo 806aec918a xtask: test-lint census rule counts a computation only where it runs on the entry
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.
2026-12-02 07:11:24 -08:00
dotCooCoo d308e9d017 xtask: check the CI shard-members lines in every shard, not in one test
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.
2026-12-02 06:38:09 -08:00
dotCooCoo 0f3bd62ddc Merge main into fix/rebalance-test-shards 2026-12-02 06:35:21 -08:00
ruchirguitar fd3e127afc xtask: web-fonts tests set their font policy and each publish run has its own scratch folder
The served-faces test passes CRAFT_FONTS_REQUIRED=0 explicitly, so a job
that sets it to 1 does not fail its background-only case, and two runs in
one process (parallel tests) no longer share the folder for the table
they throw away.
2026-12-02 19:47:53 +05:30
dotCooCoo a02c432ba2 Merge main into fix/rebalance-test-shards 2026-12-02 06:15:55 -08:00
ruchirguitar dd9f8e6d10 Web: the site publishes the interface's served fonts under fonts/ui/
The web interface font stack fetches its craft-fonts faces from the
`fonts/ui/` URLs in SERVED_FONTS, but only crates/text/build.rs's
OUT_DIR held those files: the Trunk hook copied the `fonts/<sha16>/`
faces alone. On a built site every served interface face (Noto Sans
Arabic, Thai and Georgian, NanumGothic, Noto Sans Devanagari) failed to
load, and the interface drew those scripts as missing-glyph boxes.

`cargo xtask web-fonts` now also publishes the `startup` and `demand`
faces of crates/text/web-fonts.txt under `fonts/ui/`, licence beside
each, with the same craft-fonts-build `Embed::serve` that build.rs
uses, so the files match the table's URLs and integrity values.

Test: publishes_the_interface_faces_at_their_served_urls.

Fixes #10567.
2026-12-02 19:43:47 +05:30
dotCooCoo ffa83d3a7f Merge main into fix/plugins-tree-audit-in-checks 2026-12-02 06:09:48 -08:00
dotCooCoo c3bd6d7a0b Merge main into fix/ci-select-tests 2026-12-02 06:04:42 -08:00
dotCooCoo cf51c8894c xtask: test-lint decodes string continuations in cfg_attr paths and keeps census hits for fixed ranges
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.
2026-12-02 05:55:33 -08:00
dotCooCoo 1361bb3b5c Merge main into fix/census-behavior-tables 2026-12-02 05:23:02 -08:00
dotCooCoo 1eb22f6134 xtask: test-lint census entry reads skip path segments, comment gaps and block statements
- 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.
2026-12-02 03:01:11 -08:00
dotCooCoo fde52f43a2 xtask: test-lint resolves shadowed helpers, literal selectors and aliases
- 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.
2026-12-02 02:38:11 -08:00
.CooCoo 9a7ebdd8a2 Merge pull request #10549 from dotCooCoo/fix/test-lint-plain-path-decode
xtask: test-lint decodes escapes in #[path] values
2026-12-02 02:15:50 -08:00
dotCooCoo 70e69a1750 Merge main into fix/plugins-tree-audit-in-checks 2026-12-02 02:13:53 -08:00
dotCooCoo 2b6847da7e Merge main into fix/ci-select-tests 2026-12-02 02:11:22 -08:00
dotCooCoo b8e72d686c xtask: test-lint checks a base file's blob size before reading it
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.
2026-12-02 02:11:07 -08:00
dotCooCoo 859a6b4dd3 xtask: test-lint decodes escapes in #[path] values
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.
2026-12-02 01:33:38 -08:00
dotCooCoo b65de1d729 Merge main into chore/never-run-test-allows 2026-12-02 01:21:47 -08:00