Skip to content

Adopt the Polonius-enabled nightly and retire the -Z directive - #577

Draft
leynos wants to merge 1 commit into
mainfrom
use-polonius-enabled-nightly
Draft

Adopt the Polonius-enabled nightly and retire the -Z directive#577
leynos wants to merge 1 commit into
mainfrom
use-polonius-enabled-nightly

Conversation

@leynos

@leynos leynos commented Aug 22, 2026

Copy link
Copy Markdown
Owner

Summary

This branch moves the pinned Rust toolchain from nightly-2026-06-25 to
nightly-2026-08-13 and removes every instruction that passed a
-Zpolonius directive to Cargo. Nightlies dated 2026-08-04 and later run the
Polonius alpha analysis by default, so the dated pin now carries the
borrow-checker requirement on its own and the directive is redundant.

The plumbing is removed wholesale rather than left inert. The directive is
being retired upstream, and a build that restates it is a build that can
silently drop it — the failure mode the old contract test existed to catch.
ADR-006's decision is unchanged; only the mechanism that implements it is.

Review walkthrough

Start with the two files that define the new policy:

Then the inverted contract, which is the safeguard against regression:

  • tests/polonius_toolchain_contract.rs
    — the test no longer asserts the flag is present everywhere. It now
    requires the pinned channel to be a dated nightly at or after 2026-08-04,
    and fails if any build-configuration surface reintroduces a -Zpolonius
    directive.

Then the removals themselves, which are mechanical:

  • .cargo/config.toml is deleted; carrying the flag was its only purpose.
  • Makefile
    POLONIUS_FLAGS is gone. kani-full and the binary-build recipe now set
    no RUSTFLAGS at all, so only the lint gates set it, and only to deny
    warnings.
  • tools/dev-fast/config.toml,
    and the four workflows' with.rustflags inputs.
  • docs/developers-guide.md
    — the rewritten "Toolchain and borrow checker" section, and the
    shared-action contract
    below it.

Finish with the fallout the newer toolchain surfaced, which is the least
obvious part of the branch. Cargo 1.99 no longer creates target/debug/deps/:
it runs integration tests from <profile>/build/<pkg>/<hash>/out/ and gives
every crate its own directory.

  • test_support/src/netsuke/locator.rs
    profile_dir derives the profile directory from either executable
    layout. This module is new only in the sense that it was split out of
    test_support/src/netsuke.rs, which had grown past the module line cap.
  • tests/locale_stub_ui_tests.rs
    and
    tests/command_env_ui_tests.rs
    — both UI-fixture harnesses now collect the parent directory of every
    loadable artefact Cargo reports. Note that this must accept proc-macro
    dynamic libraries as well as rlibs: a shared deps/ directory used to pick
    proc macros up as a side effect, so an rlib-only filter went unnoticed
    until each crate got its own directory, at which point dependents failed
    with E0463.

Two clippy lints new to this nightly are fixed at the source rather than
suppressed: assert_is_empty in
tests/ir_tests.rs,
src/graph_view/tests.rs
and
src/status_timing_tests.rs,
and chunks_exact_to_as_chunks in
src/hex_property_tests.rs.

Validation

All four gates run on the bumped toolchain, sequentially, from a clean tree:

make check-fmt   pass
make lint        pass  (rustdoc, clippy, and both Whitaker Dylint passes)
make test        pass  (2279/2279 nextest tests, 3 skipped; all doctests)
make markdownlint pass (85 files, 0 errors)

The Polonius default was verified empirically rather than taken from the
compiler's -Z help text, which still reports default: no. The classic
NLL problem case #3 — a conditional early return of a borrow from a map —
compiles with no flag on nightly-2026-08-13 and is rejected on
nightly-2026-06-25.

Notes

  • Kani borrow-checks under NLL. Kani manages its own supporting nightly,
    which for 0.67.0 is nightly-2025-11-21 — earlier than the Polonius
    default. Under the retired flag, make kani-full passed -Zpolonius=next
    through RUSTFLAGS and so got the analysis; it no longer does. This is
    harmless today because the tree has no POLONIUS(...)-tagged sites, but it
    is a real gap. Both
    docs/polonius.md
    and the developers' guide record it, and say to move Kani forward rather
    than reinstate the directive.
  • -Zpolonius=legacy is not an NLL fallback. It was checked: it accepts
    the same programs as the default. Classifying a new borrow-centric API
    against NLL now means compiling it on a pre-2026-08-04 nightly, which
    docs/polonius.md
    states.
  • CHANGELOG.md is unchanged. The repository follows Common Changelog
    and keeps no Unreleased section; the existing Polonius entry sits under
    the released 0.1.0-beta1 heading and describes what that release did.
    Recording this change is left to the next release cut, when the version
    heading exists.
  • The RUSTFLAGS contract model was simplified. Every recipe that still
    sets RUSTFLAGS does so for one reason — to deny warnings while
    conditionally preserving an inherited value — so the per-case
    WarningPolicy and InheritancePolicy fields had no remaining variants
    and were removed. A recipe needing a different policy will fail the
    assertions rather than pass silently, which is the signal to reintroduce
    them.

References

Summary by Sourcery

Adopt the Polonius-enabled nightly as the sole borrow-checker configuration and update tooling, tests, and documentation for the new compiler behavior.

Bug Fixes:

  • Update UI test harnesses and executable discovery to support Cargo 1.99's per-crate build directories, including proc-macro dynamic libraries.
  • Resolve new nightly Clippy warnings in tests without suppressing the lints.

Enhancements:

  • Adopt nightly-2026-08-13, where Polonius is enabled by default, and remove the retired -Zpolonius directive from repository build configuration.
  • Simplify Makefile, development, CI, and contract-test handling so the pinned toolchain is the single source of the Polonius requirement.
  • Strengthen toolchain and workflow contracts to enforce the dated-nightly minimum and prevent reintroduction of -Zpolonius.

Build:

  • Remove the repository Cargo configuration used solely to pass the Polonius flag and update build recipes to retain only their warning-denial flags.

CI:

  • Update CI, coverage, packaging, and Netsukefile workflows to use the newer pinned nightly and eliminate Polonius rustflags.

Documentation:

  • Update contributor, installation, architecture, and Polonius documentation to describe the nightly-default policy and revised registry installation command.

Tests:

  • Revise build-configuration contracts for the new toolchain policy and add coverage for Cargo's newer artifact layouts and proc-macro dependencies.

Chores:

  • Split test-support executable location logic into a dedicated module and simplify the RUSTFLAGS contract model.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Warning

Your free Security trial is over. An organization admin can activate billing to continue.

@coderabbitai

coderabbitai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 3ed2a708-b9ff-4110-a89b-f6f911cdd9d1

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

Reviewer's Guide

Moves the pinned Rust toolchain to a Polonius-default nightly and removes all -Zpolonius plumbing in favor of carrying the Polonius requirement solely via the dated nightly pin, updates CI and documentation to match, adapts test harnesses to Cargo 1.99’s new build layout, and fixes a few new clippy lints.

Sequence diagram for UI harness dependency discovery

sequenceDiagram
    participant Harness as UI test harness
    participant Cargo as Cargo 1.99
    participant Rustc as rustc fixture compiler
    Harness->>Cargo: cargo metadata/build with JSON messages
    Cargo-->>Harness: compiler-artifact loadable filenames
    Harness->>Harness: profile_dir(executable_path)
    Harness->>Rustc: Compile fixture with -L dependency=parent_directories
    Rustc-->>Harness: Fixture result
Loading

Flow diagram for the toolchain contract safeguard

flowchart TD
    Start[Build configuration] --> Channel[Read pinned channel]
    Channel --> ValidChannel{Dated nightly >= 2026-08-04?}
    ValidChannel -- No --> Fail[Contract test fails]
    ValidChannel -- Yes --> Scan[Scan Makefile, Cargo config, and workflows]
    Scan --> Directive{-Zpolonius directive found?}
    Directive -- Yes --> Fail
    Directive -- No --> Pass[Policy accepted]
Loading

File-Level Changes

Change Details Files
Adopt a newer Polonius-default nightly toolchain and retire all -Zpolonius flags, simplifying the RUSTFLAGS/CI contracts while enforcing the policy via tests.
  • Bump rust-toolchain channel from nightly-2026-06-25 to nightly-2026-08-13 and document that Polonius is enabled by default on >= 2026-08-04 nightlies.
  • Delete .cargo/config.toml and remove the POLONIUS_FLAGS Make variable; Makefile recipes that set RUSTFLAGS now only add -D warnings and preserve inherited flags.
  • Update all GitHub workflows to use the new nightly, drop -Zpolonius from with.rustflags, and keep -D warnings only where gating on warnings is intended.
  • Tighten the toolchain/Polonius contract test to require a dated nightly >= 2026-08-04 and to assert that no build configuration file reintroduces a -Zpolonius directive, while updating the shared-actions expectations.
  • Simplify the Makefile RUSTFLAGS contract tests by removing per-case policy enums and asserting uniform behaviour (conditional inheritance plus warnings-as-errors).
rust-toolchain.toml
Makefile
.github/workflows/ci.yml
.github/workflows/coverage-main.yml
.github/workflows/netsukefile-test.yml
.github/workflows/build-and-package.yml
tests/polonius_toolchain_contract.rs
tests/makefile_test_target.rs
tests/makefile_test_target/rustflags.rs
.cargo/config.toml
Update ADRs, guides, and policy docs to reflect the new Polonius-default model and the simplified RUSTFLAGS and CI contracts, including Kani/trybuild consequences and registry-install requirements.
  • Revise ADR-006, Polonius migration notes, and related design docs to describe Polonius as enabled by default on the pinned nightly and to treat -Zpolonius as historical context only.
  • Update developers’ guide, AGENTS, README, users’ guide, quickstart, and ADR-007 to remove references to -Zpolonius=next, document the "no -Z directive" rule, and adjust CI shared-action and dev-fast composition rules.
  • Adjust documentation/tests to pin the new nightly in crates.io install commands and to assert only the toolchain selection (no RUSTFLAGS requirement) for registry installs.
  • Clarify Kani integration and harness behaviour now that Polonius is toolchain-driven instead of flag-driven, keeping direct-compile harnesses where they are still the better option.
docs/adr-006-adopt-polonius-nightly-toolchain.md
docs/polonius.md
docs/developers-guide.md
docs/users-guide.md
docs/quickstart.md
docs/netsuke-design.md
docs/adr-007-publish-as-netsuke-build.md
AGENTS.md
README.md
docs/netsuke-design.md
scripts/dev-fast-common.sh
tools/dev-fast/config.toml
tests/documentation_installation_tests.rs
tests/sha2_migration_guard_tests.rs
tests/kani_cfg_ui_tests.rs
tests/locale_stub_ui_tests.rs
tests/command_env_ui_tests.rs
Adapt test harnesses to Cargo 1.99’s new build/executable layout, including robust binary and dependency discovery that works across both old and new directory structures and handles proc-macro dynamic libraries.
  • Extract the binary locator into test_support::netsuke::locator, introduce profile_dir to normalize both target/debug/deps and target/debug/build/.../out layouts, and add unit tests for both plus edge cases.
  • Update the description and docs of the locator to account for the new integration-test executable locations and to use the derived profile directory for fallbacks.
  • Change UI harnesses for locale and command-env tests to collect parent directories of all loadable artefacts (rlibs and platform DLLs) from Cargo JSON output, so per-crate build directories and proc-macro dylibs are handled correctly.
  • Extend tests around the harnesses to cover proc-macro dylib directories and the new build layout behaviour.
test_support/src/netsuke/locator.rs
test_support/src/netsuke/mod.rs
docs/developers-guide.md
tests/locale_stub_ui_tests.rs
tests/command_env_ui_tests.rs
Fix clippy lints and minor test expectations to comply with the new nightly’s lint set.
  • Replace assert!(…is_empty()) with equality against explicit empty vectors in several tests to satisfy assert_is_empty suggestions.
  • Rewrite the hex decoding helper to use as_chunks::<2>() instead of chunks_exact(2) for chunks_exact_to_as_chunks lint compliance.
tests/ir_tests.rs
src/graph_view/tests.rs
src/status_timing_tests.rs
src/hex_property_tests.rs

Possibly linked issues


Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

codescene-access[bot]

This comment was marked as outdated.

Bump the pinned toolchain from nightly-2026-06-25 to nightly-2026-08-13.
Nightlies dated 2026-08-04 and later run the Polonius alpha analysis by
default, so the dated pin now carries the borrow-checker requirement on
its own and every `-Zpolonius=next` directive is redundant.

Remove the flag plumbing wholesale rather than leave it inert. The
directive is being retired upstream, and a build that restates it is a
build that can silently drop it:

- delete `.cargo/config.toml`, whose only purpose was carrying the flag;
- drop the Makefile's `POLONIUS_FLAGS` variable and its uses, leaving
  `kani-full` and the binary-build recipe setting no `RUSTFLAGS` at all;
- drop the flag from the dev-fast Cargo fragment and from the four
  workflows' `with.rustflags` inputs;
- drop it from the documented registry-install command.

Invert the contract test accordingly: `polonius_toolchain_contract` now
requires the pinned channel to be a dated nightly at or after 2026-08-04
and fails if any build configuration reintroduces a `-Zpolonius`
directive, instead of asserting the flag is present everywhere.

Fix the fallout the newer toolchain surfaces, at the source rather than
by suppression:

- Cargo 1.99 no longer creates `target/debug/deps/`, running integration
  tests from `<profile>/build/<pkg>/<hash>/out/` and giving every crate
  its own directory. Teach the `netsuke` binary locator to derive the
  profile directory from either layout, and teach the two UI-fixture
  harnesses to collect the parent of every loadable artefact Cargo
  reports. The latter must accept proc-macro dynamic libraries as well
  as rlibs: a shared `deps/` used to pick them up for free, so an
  rlib-only filter went unnoticed until each crate got its own
  directory.
- Satisfy clippy's new `assert_is_empty` and `chunks_exact_to_as_chunks`
  lints.
- Split `test_support/src/netsuke.rs`, which grew past the module line
  cap, into a parent module and a `locator` submodule.

Kani's supporting nightly (2025-11-21 for 0.67.0) predates the Polonius
default, so `make kani-full` borrow-checks under NLL. That is harmless
while no `POLONIUS(...)` sites exist; the guide and migration notes
record the gap and say to move Kani forward rather than reinstate the
directive.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@leynos
leynos force-pushed the use-polonius-enabled-nightly branch from d828eff to f1923cd Compare August 22, 2026 02:49
codescene-access[bot]

This comment was marked as outdated.

@codescene-access codescene-access Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No quality gates enabled for this code.

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