Skip to content

Add edition checks for some tests that had divergent output #142255

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 2 commits into from
Jun 26, 2025

Conversation

estebank
Copy link
Contributor

@estebank estebank commented Jun 9, 2025

In order to expose edition dependent divergences in some tests in the test suite, add explicit edition annotations. Some of these tests might require additional work to avoid the divergences, as they might have been unintentional. These are not exhaustive changes, purely opportunistic while I was looking at something else.

@rustbot
Copy link
Collaborator

rustbot commented Jun 9, 2025

r? @fee1-dead

rustbot has assigned @fee1-dead.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 9, 2025
@rust-log-analyzer

This comment has been minimized.

@estebank
Copy link
Contributor Author

estebank commented Jun 9, 2025

cc rust-lang/compiler-team#861

@estebank estebank force-pushed the edition-diagnostic-changes branch from 85c28a9 to ce7480d Compare June 9, 2025 18:20
Comment on lines +1 to +23
error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
--> $DIR/issue-54895.rs:18:40
|
LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> {
| ^^^^^^^^^^^^^^^ `impl Trait` implicitly captures all lifetimes in scope
|
note: lifetime declared here
--> $DIR/issue-54895.rs:18:20
|
LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> {
| ^^

error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait`
--> $DIR/issue-54895.rs:18:53
|
LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> {
| ^^
|
note: lifetime declared here
--> $DIR/issue-54895.rs:18:20
|
LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> {
| ^^
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These duplicated errors are unfortunate and quite common throughout the test suite.

Comment on lines +4 to +5
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
| -- this generic parameter must be used with a generic lifetime parameter
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The last edition changes the span being pointed at in such a way that the wording should change (or get the span from previous editions back).

@fee1-dead
Copy link
Member

The parts about bare trait names in type position LGTM, but it would probably be better if someone else who knew about RPITs better to assess the changes in those tests

r? compiler

@rustbot rustbot assigned BoxyUwU and unassigned fee1-dead Jun 11, 2025
@BoxyUwU
Copy link
Member

BoxyUwU commented Jun 23, 2025

r? compiler

@rustbot rustbot assigned WaffleLapkin and unassigned BoxyUwU Jun 23, 2025
Copy link
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

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

Some diagnostics are bad, but that's a pre-existing issue. @estebank would you mind opening issues for the bad cases here?

This improves test coverage, which seems like a good idea.

Comment on lines +1 to +3
//@revisions: edition2015 edition2021
//@[edition2015] edition:2015
//@[edition2021] edition:2021
Copy link
Member

Choose a reason for hiding this comment

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

maybe we should have a shorthand for this 🤔

@WaffleLapkin
Copy link
Member

@bors r=fee1-dead,WaffleLapkin rollup

@bors
Copy link
Collaborator

bors commented Jun 24, 2025

📌 Commit ce7480d has been approved by fee1-dead,WaffleLapkin

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 24, 2025
workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 25, 2025
…s, r=fee1-dead,WaffleLapkin

Add edition checks for some tests that had divergent output

In order to expose edition dependent divergences in some tests in the test suite, add explicit `edition` annotations. Some of these tests might require additional work to *avoid* the divergences, as they might have been unintentional. These are not exhaustive changes, purely opportunistic while I was looking at something else.
@rustbot

This comment has been minimized.

@workingjubilee
Copy link
Member

This needs to be rebased and blessed.

@bors r-

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jun 25, 2025
@workingjubilee
Copy link
Member

@bors rollup=iffy

@rust-log-analyzer

This comment has been minimized.

@estebank
Copy link
Contributor Author

@bors r=fee1-dead,WaffleLapkin

@bors
Copy link
Collaborator

bors commented Jun 25, 2025

📌 Commit 8c3a033 has been approved by fee1-dead,WaffleLapkin

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 25, 2025
@workingjubilee
Copy link
Member

@bors p=5

workingjubilee added a commit to workingjubilee/rustc that referenced this pull request Jun 26, 2025
…s, r=fee1-dead,WaffleLapkin

Add edition checks for some tests that had divergent output

In order to expose edition dependent divergences in some tests in the test suite, add explicit `edition` annotations. Some of these tests might require additional work to *avoid* the divergences, as they might have been unintentional. These are not exhaustive changes, purely opportunistic while I was looking at something else.
bors added a commit that referenced this pull request Jun 26, 2025
Rollup of 17 pull requests

Successful merges:

 - #124595 (Suggest cloning `Arc` moved into closure)
 - #139594 (Simplify `ObligationCauseCode::IfExpression`)
 - #141311 (make `tidy-alphabetical` use a natural sort)
 - #141648 ([rustdoc] Do not emit redundant_explicit_links lint if the doc comment comes from expansion)
 - #142255 (Add edition checks for some tests that had divergent output)
 - #142285 (tests: Do not run afoul of asm.validity.non-exhaustive in input-stats)
 - #142549 (small iter.intersperse.fold() optimization)
 - #142637 (Remove some glob imports from the type system)
 - #142647 ([perf] Compute hard errors without diagnostics in impl_intersection_has_impossible_obligation)
 - #142700 (Remove incorrect comments in `Weak`)
 - #142884 (StableMIR: Add method to retrieve body of coroutine)
 - #142925 (Rewrite `.gitattributes` CRLF ui tests into run-make tests)
 - #143001 (Rename run always )
 - #143010 (Update `browser-ui-test` version to `0.20.7`)
 - #143015 (Add `sym::macro_pin` diagnostic item for `core::pin::pin!()`)
 - #143020 (codegen_fn_attrs: make comment more precise)
 - #143033 (Expand const-stabilized API links in relnotes)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Collaborator

bors commented Jun 26, 2025

⌛ Testing commit 8c3a033 with merge 3b9d04c...

@bors
Copy link
Collaborator

bors commented Jun 26, 2025

☀️ Test successful - checks-actions
Approved by: fee1-dead,WaffleLapkin
Pushing 3b9d04c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jun 26, 2025
@bors bors merged commit 3b9d04c into rust-lang:master Jun 26, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jun 26, 2025
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 8f21a5c (parent) -> 3b9d04c (this PR)

Test differences

Show 84 test diffs

Stage 1

  • [ui] tests/ui/did_you_mean/bad-assoc-ty.rs: pass -> [missing] (J1)
  • [ui] tests/ui/did_you_mean/bad-assoc-ty.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/did_you_mean/bad-assoc-ty.rs#edition2021: [missing] -> pass (J1)
  • [ui] tests/ui/feature-gates/feature-gate-unsized_fn_params.rs: pass -> [missing] (J1)
  • [ui] tests/ui/feature-gates/feature-gate-unsized_fn_params.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/feature-gates/feature-gate-unsized_fn_params.rs#edition2021: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs#edition2021: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/hidden-lifetimes.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/hidden-lifetimes.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/hidden-lifetimes.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/issues/issue-54895.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/issues/issue-54895.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/issues/issue-54895.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/issues/issue-79099.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/issues/issue-79099.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/issues/issue-79099.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/precise-capturing/dyn-use.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/precise-capturing/dyn-use.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/precise-capturing/dyn-use.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs: pass -> [missing] (J1)
  • [ui] tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/imports/import-from-missing-star-2.rs: pass -> [missing] (J1)
  • [ui] tests/ui/imports/import-from-missing-star-2.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/imports/import-from-missing-star-2.rs#edition2024: [missing] -> pass (J1)
  • [ui] tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs: pass -> [missing] (J1)
  • [ui] tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs#edition2015: [missing] -> pass (J1)
  • [ui] tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs#edition2024: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/did_you_mean/bad-assoc-ty.rs: pass -> [missing] (J0)
  • [ui] tests/ui/did_you_mean/bad-assoc-ty.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/did_you_mean/bad-assoc-ty.rs#edition2021: [missing] -> pass (J0)
  • [ui] tests/ui/feature-gates/feature-gate-unsized_fn_params.rs: pass -> [missing] (J0)
  • [ui] tests/ui/feature-gates/feature-gate-unsized_fn_params.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/feature-gates/feature-gate-unsized_fn_params.rs#edition2021: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs#edition2021: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/hidden-lifetimes.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/hidden-lifetimes.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/hidden-lifetimes.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/issues/issue-54895.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/issues/issue-54895.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/issues/issue-54895.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/issues/issue-79099.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/issues/issue-79099.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/issues/issue-79099.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/precise-capturing/dyn-use.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/precise-capturing/dyn-use.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/precise-capturing/dyn-use.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs: pass -> [missing] (J0)
  • [ui] tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/imports/import-from-missing-star-2.rs: pass -> [missing] (J0)
  • [ui] tests/ui/imports/import-from-missing-star-2.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/imports/import-from-missing-star-2.rs#edition2024: [missing] -> pass (J0)
  • [ui] tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs: pass -> [missing] (J0)
  • [ui] tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs#edition2015: [missing] -> pass (J0)
  • [ui] tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs#edition2024: [missing] -> pass (J0)

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard 3b9d04c62f74b9be46c3ba56cf8393529aa81d26 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-aarch64-linux: 5750.9s -> 8031.3s (39.7%)
  2. dist-x86_64-apple: 7529.1s -> 10332.5s (37.2%)
  3. dist-apple-various: 9349.8s -> 7703.9s (-17.6%)
  4. aarch64-apple: 4527.2s -> 5056.3s (11.7%)
  5. dist-x86_64-solaris: 5130.8s -> 5642.1s (10.0%)
  6. dist-powerpc64le-linux-musl: 4917.1s -> 5293.8s (7.7%)
  7. x86_64-apple-2: 5531.8s -> 5945.5s (7.5%)
  8. dist-aarch64-apple: 6441.5s -> 6011.5s (-6.7%)
  9. x86_64-apple-1: 6713.2s -> 7134.1s (6.3%)
  10. dist-armv7-linux: 4840.5s -> 5113.3s (5.6%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (3b9d04c): comparison URL.

Overall result: ❌ regressions - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.2% [0.2%, 0.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Max RSS (memory usage)

Results (secondary 2.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.2% [2.2%, 2.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (secondary -9.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-9.7% [-11.5%, -4.0%] 7
All ❌✅ (primary) - - 0

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 691.142s -> 690.7s (-0.06%)
Artifact size: 372.05 MiB -> 372.13 MiB (0.02%)

Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe `@nikomatsakis` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? `@jackh726`

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ``@nikomatsakis`` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ``@jackh726``

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ```@nikomatsakis``` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ```@jackh726```

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ````@nikomatsakis```` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ````@jackh726````

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe `````@nikomatsakis````` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? `````@jackh726`````

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ``````@nikomatsakis`````` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ``````@jackh726``````

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ```````@nikomatsakis``````` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ```````@jackh726```````

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
Zalathar added a commit to Zalathar/rust that referenced this pull request Aug 10, 2025
Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ````````@nikomatsakis```````` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](rust-lang#139587), and [amanda's SCCs rework](rust-lang#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when rust-lang#142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ````````@jackh726````````

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes rust-lang#135646, a diagnostics ICE from the previous implementation.
rust-timer added a commit that referenced this pull request Aug 10, 2025
Rollup merge of #143093 - lqd:polonius-pre-alpha, r=jackh726

Simplify polonius location-sensitive analysis

This PR reworks the location-sensitive analysis into what we think is a worthwhile subset of the datalog analysis. A sort of polonius alpha analysis that handles NLL problem case 3 and more, but is still using the faster "reachability as an approximation of liveness", as well as the same loans-in-scope computation as NLLs -- and thus doesn't handle full flow-sensitivity like the datalog implementation.

In the last few months, we've identified this subset as being actionable:
- we believe we can make a stabilizable version of this analysis
- it is an improvement over the status quo
- it can also be modeled in a-mir-formality, or some other formalism, for assurances about soundness, and I believe ````````@nikomatsakis```````` is interested in looking into this during H2.
- and we've identified the areas of work we wish to explore later to gradually expand the supported cases: the differences between reachability and liveness, support of kills, and considerations of time-traveling, for example.

The approach in this PR is to try less to have the graph only represent live paths, by checking whether we reach a live region during traversal and recording the loan as live there, instead of equating traversal with liveness like today because it has subtleties with the typeck edges in statements (that could forward loans to the successor point without ensuring their liveness). We can then also simplify these typeck stmt edges. And we also can simplify traversal by removing looking at kills, because that's enough to handle a bunch of NLL problem 3 cases -- and we can gradually support them more and more in traversal in the future, to reduce the approximation of liveness.

There's still some in-progress pieces of work w/r/t opaque types that I'm expecting [lcnr's opaque types rework](#139587), and [amanda's SCCs rework](#130227) to handle. That didn't seem to show up in tests until I rebased today (and shows lack of test coverage once again) when #142255 introduced a couple of test failures with the new captures rules from edition 2024. It's not unexpected since we know more work is needed with member constraints (and we're not even using SCCs in this prototype yet)

I'll look into these anyways, both for future work, and checking how these other 2 PRs would change things.

---

I'm not sure the following means a lot until we have some formalism in-place, but:
- I've changed the polonius compare-mode to use this analysis: the tests pass with it, except 2 cases with minor diagnostics differences, and the 2 edition 2024 opaque types one I mentioned above and need to investigate
- things that are expected to work still do work: it bootstraps, can run our rustc-perf benchmarks (and the results are not even that bad), and a crater run didn't find any regressions (forgetting that crater currently fails to test around a quarter of all crates 👼)
- I've added tests with improvements, like the NLL problem case 3 and others, as well as some that behave the same as NLLs today and are thus worse than the datalog implementation

r? ````````@jackh726````````

(no rush I know you're deep in phd work and "implmentating" the new trait solver for r-a :p <3)

This also fixes #135646, a diagnostics ICE from the previous implementation.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants