|
| 1 | +# Scalable Polonius support on nightly |
| 2 | + |
| 3 | +| Metadata | | |
| 4 | +| --- | --- | |
| 5 | +| Owner(s) | @lqd | |
| 6 | +| Teams | [types] | |
| 7 | +| Status | Proposed | |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +## Summary |
| 12 | + |
| 13 | +Keep working on implementing a native rustc version of the [Polonius][pc3] next generation borrow checking algorithm, that would scale better than the previous [datalog] implementation, continuing from the [2024h2 goal](https://rust-lang.github.io/rust-project-goals/2024h2/Polonius.html). |
| 14 | + |
| 15 | +[datalog]: https://github.com/rust-lang/polonius |
| 16 | + |
| 17 | +## Motivation |
| 18 | + |
| 19 | +Polonius is an improved version of the borrow checker that [resolves common limitations of the borrow checker][pc3] and which is needed to support future patterns such as "lending iterators" (see [#92985]). Its model also prepares us for further improvements in the future. |
| 20 | + |
| 21 | +Some support exists on nightly, but this [older prototype][datalog] has no path to stabilization due to scalability issues. We need an improved architecture and implementation to fix these issues. |
| 22 | + |
| 23 | +[pc3]: https://blog.rust-lang.org/inside-rust/2023/10/06/polonius-update.html#background-on-polonius |
| 24 | + |
| 25 | +### The next six months |
| 26 | + |
| 27 | +* Complete the ongoing work to land polonius on nightly |
| 28 | + |
| 29 | +### The "shiny future" we are working towards |
| 30 | + |
| 31 | +Stable support for Polonius. |
| 32 | + |
| 33 | +## Ownership and team asks |
| 34 | + |
| 35 | +**Owner:** lqd |
| 36 | + |
| 37 | +Other support provided by @amandasystems as part of her PhD. |
| 38 | + |
| 39 | +[amanda]: https://github.com/amandasystems |
| 40 | + |
| 41 | +| Subgoal | Owner(s) or team(s) | Notes | |
| 42 | +| ---------------- | -------------------- | -------------- | |
| 43 | +| Design review | @nikomatsakis | | |
| 44 | +| Implementation | @lqd, @amandasystems | | |
| 45 | +| Standard reviews | ![Team][] [types] | @matthewjasper | |
| 46 | + |
| 47 | +### Support needed from the project |
| 48 | + |
| 49 | +We expect most support to be needed from the types team, for design, reviews, interactions with the trait solver, and so on. We expect @nikomatsakis, leading the polonius working group and design, to provide guidance and design time, and @compiler-errors and @matthewjasper to help with reviews. |
| 50 | + |
| 51 | +## Outputs and milestones |
| 52 | + |
| 53 | +### Outputs |
| 54 | + |
| 55 | +Nightly implementation of polonius that passes [NLL problem case #3][pc3] and accepts lending iterators ([#92985]). |
| 56 | + |
| 57 | +Performance should be reasonable enough that we can run the full test suite, do crater runs, and test it on CI, without significant slowdowns. We do not expect to be production-ready yet by then, and therefore the implementation would still be gated under a nightly -Z feature flag. |
| 58 | + |
| 59 | +As our model is a superset of NLLs, we expect little to no diagnostics regressions, but improvements would probably still be needed for the new errors. |
| 60 | + |
| 61 | +### Milestones |
| 62 | + |
| 63 | +Note: some of these are currently being worked on as part of the 2024h2 goal, and could be completed before the 2025h1 period. |
| 64 | + |
| 65 | +| Milestone | Contributor | Notes | |
| 66 | +| ---------------------------------------------------------------------------------- | -------------- | ----- | |
| 67 | +| Factoring out higher-ranked concerns from the main path | @amandasystems | | |
| 68 | +| ↳ [x] rewrite invalid universe constraints with outlives `'static` constraints | | [PR 123720](https://github.com/rust-lang/rust/pull/123720) | |
| 69 | +| ↳ [ ] completely remove placeholders | | in progress [PR 130227](https://github.com/rust-lang/rust/pull/130227) | |
| 70 | +| Location-sensitive prototype on nightly | @lqd | in progress | |
| 71 | +| ↳ [x] create structures for location-dependent outlives constraints | | | |
| 72 | +| ↳ [x] build new constraint graph from typeck constraints and liveness constraints | | | |
| 73 | +| ↳ [x] update NLLs for required changes to local & region liveness, loan liveness & loan scopes, (possibly unreachable) kills, bidirectional traversal & active loans | | | |
| 74 | +| ↳ [ ] limit regressions about diagnostics when using the new constraints on diagnostics tailored to the old constraints | | | |
| 75 | +| ↳ [ ] land on nightly under a `-Z` flag | | | |
| 76 | +| [x] Debugging / dump tool for analysis of location-sensitive analysis | @lqd | | |
| 77 | +| [ ] Tests and validation of location-sensitive Polonius | @lqd | | |
| 78 | +| ↳ [ ] make the full test suite pass | | in progress | |
| 79 | +| ↳ [ ] do a crater run for assertions and backwards-compatibility | | | |
| 80 | +| ↳ [ ] expand test suite with tests about the new capabilities | | | |
| 81 | +| [ ] Location-sensitive pass on nightly, tested on CI | @lqd | | |
0 commit comments