-
Notifications
You must be signed in to change notification settings - Fork 0
Add optional Polonius support to generated projects #78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7cfad2c
Add optional Polonius support to generated projects
leynos d17cb5f
Strengthen Polonius review contracts
leynos e7db625
Complete Polonius tooling propagation
leynos 2cda90e
Tighten Polonius contract diagnostics
leynos 40108c6
Format replayed tooling contract tests
leynos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| # ADR-004: Make Polonius support optional | ||
|
|
||
| ## Status | ||
|
|
||
| Accepted. | ||
|
|
||
| ## Context | ||
|
|
||
| Polonius permits borrow-centric internal APIs that the stable non-lexical | ||
| lifetime analysis rejects, but its alpha analysis still requires a dated | ||
| nightly toolchain and `-Zpolonius=next`. Applications can usually accept that | ||
| binding, while reusable libraries often need wider compiler compatibility. | ||
| Cargo build flags are also replaced whenever tooling supplies `RUSTFLAGS`, so | ||
| an enabled project must preserve the Polonius flag across every such build | ||
| surface. | ||
|
|
||
| ## Decision | ||
|
|
||
| An `enable_polonius` Copier choice defaults to enabled for applications and | ||
| disabled for libraries, with either default available for explicit override. | ||
| Enabled projects propagate `-Zpolonius=next` through Cargo, Make, coverage, | ||
| Continuous Integration (CI) and release builds. This consistent propagation | ||
| establishes a single, explicit toolchain contract across every supported build | ||
| surface. Enabled projects require a dated nightly toolchain, and every explicit | ||
| `RUSTFLAGS` value must remain synchronized with the configured Polonius flag. | ||
|
|
||
| ## Progress and outcome | ||
|
|
||
| The template now renders the option, pinned toolchain, compiler flags, policy | ||
| guidance, CI and release configuration for the selected state. Parent-template | ||
| contract and compilation tests cover enabled and disabled applications and | ||
| libraries. The implementation and its validation are complete; future | ||
| generated projects retain an explicit opt-out or opt-in as their compatibility | ||
| requirements change. | ||
|
|
||
| ## Risks | ||
|
|
||
| - A pinned nightly can become unavailable or acquire regressions and therefore | ||
| requires deliberate upgrades. | ||
| - A new build path that overrides `RUSTFLAGS` can silently omit Polonius unless | ||
| its rendered contract is extended and tested. | ||
| - Enabling borrow-centric APIs can make source builds fail under stable Rust or | ||
| plain nightly without `-Zpolonius=next`. | ||
|
|
||
| ## Consequences | ||
|
|
||
| - Generated applications adopt Polonius by default; generated libraries keep | ||
| wider compiler compatibility by default. | ||
| - Opted-in projects document their nightly requirement and preserve the flag | ||
| across supported build paths. | ||
| - Maintainers must treat the Copier answer, dated channel, and explicit flag | ||
| propagation as one toolchain policy when updating generated projects. |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| # Migrating to 0.2.0 | ||
|
|
||
| Version 0.2.0 adds the `enable_polonius` Copier prompt. The prompt controls | ||
| whether generated projects use the nightly Polonius borrow-checking analysis | ||
| through `-Zpolonius=next`. | ||
|
|
||
| ## Update an existing project | ||
|
|
||
| 1. Commit or otherwise preserve local changes before updating. | ||
| 2. Run `copier update` using the same answers file and template source as the | ||
| existing project. | ||
| 3. Review the new `enable_polonius` answer before accepting the rendered | ||
| changes. Applications default to enabled; libraries default to disabled. | ||
| Either value can be overridden explicitly. | ||
| 4. Review changes to the Rust toolchain, Cargo configuration, Makefile, | ||
| coverage and release workflows as one toolchain-policy update. | ||
| 5. Run the generated project's full quality gates after resolving Copier | ||
| conflicts. | ||
|
|
||
| Enabling Polonius binds the generated project to its configured dated nightly | ||
| toolchain. Every build path that sets `RUSTFLAGS` explicitly must include | ||
| `-Zpolonius=next` because an explicit value replaces Cargo's build-level | ||
| flags. Disabling Polonius retains the wider compiler compatibility expected by | ||
| libraries, although the template still uses its configured nightly toolchain. | ||
|
|
||
| The rationale and accepted constraints are recorded in | ||
| [ADR-004](../adr-004-optional-polonius-support.md). |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.