Skip to content

Fix round-30 route collector findings (cfg twins, #[path] trees) - #449

Open
owjs3901 wants to merge 2 commits into
mainfrom
fix/collector-round30
Open

owjs3901 wants to merge 2 commits into
mainfrom
fix/collector-round30

Conversation

@owjs3901

Copy link
Copy Markdown
Contributor

Summary

Fixes the round-30 macrorest-1 collector findings (R30-M1, R30-L1, R30-L2) and the #[path] child-directory assumption they depended on.

  • R30-M1: cfg-disjoint twin mod declarations (#[cfg(unix)] mod m; beside #[cfg(not(unix))] mod m;) were ANDed by the generator into an always-false predicate, so the route was never mounted on the slow path. They are now ORed into one any(all(..), all(..)). An ungated declaration among the twins loads the module in every build and gates nothing.
  • R30-L1 (round-29 regression): an ungated #[path] module loads only its target in every build. Its test-gated child is now test-only; the walk follows the target's own mod declarations instead of a directory prefix.
  • R30-L2: ungated mod and #[path] declarations are recorded for every declaring file, not only files with cfg and test text. A declaration counts only when its declaring file is itself loaded in every build, so an ungated mod inside a test-only file no longer makes its child production.
  • #[path] directory rule (checked with rustc): children of a #[path] file load beside that file, e.g. #[path = "beside/support.rs"] with mod child; resolves to beside/child.rs, not beside/support/child.rs. Only a mod.rs target's children sit in its directory (both forms verified with a scratch crate). The old child_dir assumption is removed.

The new walk is in crates/vespera_macro/src/collector/test_scope/path_tree.rs (sidecar, keeps test_scope.rs under the 1000-line cap).

Test plan

  • cargo test -p vespera_macro (5893 lib tests + integration + trybuild)
  • cargo test -p vespera (all targets)
  • cargo clippy -p vespera_macro --all-targets -- -D warnings
  • New tests for R30-M1 (table cases plus a slow-path route mounted under the any(...) predicate), R30-L1, R30-L2, the beside-layout cases, and the declarer-gating cases

🤖 Generated with Claude Code

owjs3901 and others added 2 commits November 20, 2026 00:18
- module_cfg_predicates: cfg-disjoint twin `mod` declarations of one
  module are ORed (`any(all(..), all(..))`), not ANDed into an
  always-false predicate; an ungated declaration loads the module in
  every build and gates nothing.
- #[path] trees: an ungated #[path] module loads only its target in
  every build, so a test-gated child of it stays test-only. The children
  of a #[path] target are walked from its own `mod` declarations with
  rustc's directory rules (a non-mod.rs target owns the directory beside
  it), replacing the directory-prefix test.
- Every file that declares a `mod` is read for ungated `mod` and #[path]
  declarations, not only files with cfg and test text. A declaration
  counts only when its declaring file is itself loaded in every build.
- Tests for each finding, including the twin route mounted under the
  any(...) predicate on the slow path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The crate scan in test_scope applied its own stem rule to an inline
#[path] inside a path-loaded non-mod-rs file (`beside/support.rs` names
`beside/support/inner/..`), while rustc resolves it beside the file
(`beside/inner/..`). Every #[path] target now comes from path_tree's
walk from lib.rs / main.rs, the same resolver the module trees use, so
the stem rule and the per-file directory guess are gone. The gated
mod-name scan keeps only by-name chains.

Test: inline_path_of_a_path_loaded_file_resolves_beside_it_not_under_its_stem.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@owjs3901
owjs3901 force-pushed the fix/collector-round30 branch from 997051c to 72fbf32 Compare November 19, 2026 15:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant