Skip to content
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

Revert #126024 "Do not use global caches if opaque types can be defined" #132075

Closed
wants to merge 3 commits into from

Conversation

lqd
Copy link
Member

@lqd lqd commented Oct 23, 2024

This PR prepares a revert of #126024 as discussed on zulip, because of its regressions to compilation times vs unclear soundness fix. Opening as draft for discussion between @compiler-errors and @lcnr.


#126024 didn't fix the ICE in #119272 (proof). Enabling the new solver in coherence did fix both the codegen ICE and incorrectly accepting the code in the first place.

It seems the theoretical unsoundness fixed in #126024 didn't yet have an MCVE showcasing the issue, and didn't have tests. The correct fix is in principle to use the new solver.

However, that is not happening soon and until then #126024 has a big impact on compile-times in some cases:


I didn't add the crash test for #119272 back, and the auto-traits/opaque_type_candidate_selection.rs test was deleted in #130654. I assume the latter was because there already was coverage for such a case, but if not I can add that test back, updated for -Znext-solver=coherence. I don't have an MCVE for #132064 but if needed, I could try to minimize it.

Fixes #132064.

@rustbot
Copy link
Collaborator

rustbot commented Oct 23, 2024

r? @cjgillot

rustbot has assigned @cjgillot.
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 Oct 23, 2024
@rust-log-analyzer

This comment has been minimized.

@lqd
Copy link
Member Author

lqd commented Oct 23, 2024

The first failure is just a test needing expectations updated, but the second is that type-alias-impl-trait/reveal_local.rs now ICEs in #122192 code, which is understandable since #126024 was extracted from it.

Just to check, I also tried to revert #122192 and all UI tests passed.

@bors
Copy link
Contributor

bors commented Oct 30, 2024

☔ The latest upstream changes (presumably #132349) made this pull request unmergeable. Please resolve the merge conflicts.

@compiler-errors
Copy link
Member

Hi @lqd, can you rebase this PR and getting this into a landable state? I'm in favor of landing this, especially because the unsoundness it fixes was never really deeply investigated AFAICT, and it's affecting people on stable. cc @lcnr

@compiler-errors
Copy link
Member

@rustbot author

@rustbot rustbot 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-review Status: Awaiting review from the assignee but also interested parties. labels Nov 4, 2024
lqd added 3 commits November 5, 2024 00:18
the compile time impact is too great for a theoretical issue.

This basically reverts commit 61b5e11
This avoids the ICE in `tests/ui/type-alias-impl-trait/reveal_local.rs`.
@lqd
Copy link
Member Author

lqd commented Nov 5, 2024

Hi @lqd, can you rebase this PR and getting this into a landable state?

Hi @compiler-errors,

I can get this into a reviewable state (and just pushed), but I'm not sure I can get it into a landable state per se: this is getting too subtle for my puny brain.

As mentioned in my last comment, some of #122192 depends on #126024, and I've also reverted part of it so that tests pass. This seems somewhat ok as it was just an unreachable!() protecting the previous status quo, but I'm not sure of the subtle effects and if it was only exercised via TAITs.

I've tried to add comments, but we'd likely need actual an issue to track the possible unsoundness / not using the global cache when defining opaque types, even if it would end up being fixed only when the new solver stabilizes.

So that's why it's still in draft. At this point, I'm not sure if I'm just wasting your time and it'd have been faster if you/lcnr had done the revert instead.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 5, 2024
@compiler-errors
Copy link
Member

Oof, sorry I have not been following closely enough to understand the problem with the revert. I'll take a closer look -- thanks for pushing what you have.

bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 5, 2024
…, r=<try>

Only disable cache if predicate has opaques within it

This is an alternative to rust-lang#132075.

It doesn't totally fix the issue, for example: `lemmy` goes from 1:29 (on rust 1.81) to 9:53 (on nightly) to 4:07 (after this PR). But I think it's at least *more* sound than a total revert :/

vibes??? r? lcnr
bors added a commit to rust-lang-ci/rust that referenced this pull request Nov 6, 2024
…, r=lcnr

Only disable cache if predicate has opaques within it

This is an alternative to rust-lang#132075.

This refines the check implemented in rust-lang#126024 to only disable the global cache if the predicate being considered has opaques in it. This is still theoretically unsound, since goals can indirectly rely on opaques in the defining scope, but we're much less likely to hit it.

It doesn't totally fix rust-lang#132064: for example, `lemmy` goes from 1:29 (on rust 1.81) to 9:53 (on nightly) to 4:07 (after this PR). But I think it's at least *more* sound than a total revert :/

r? lcnr
@bors
Copy link
Contributor

bors commented Nov 7, 2024

☔ The latest upstream changes (presumably #132625) made this pull request unmergeable. Please resolve the merge conflicts.

@lqd
Copy link
Member Author

lqd commented Nov 7, 2024

@lcnr @compiler-errors do you want me to close this PR?

@lcnr
Copy link
Contributor

lcnr commented Nov 7, 2024

yeah, I'd think so 👍 thanks for tracking this work and making sure we actually do something here

@lcnr lcnr closed this Nov 7, 2024
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Nov 28, 2024
Only disable cache if predicate has opaques within it

This is an alternative to rust-lang/rust#132075.

This refines the check implemented in rust-lang/rust#126024 to only disable the global cache if the predicate being considered has opaques in it. This is still theoretically unsound, since goals can indirectly rely on opaques in the defining scope, but we're much less likely to hit it.

It doesn't totally fix rust-lang/rust#132064: for example, `lemmy` goes from 1:29 (on rust 1.81) to 9:53 (on nightly) to 4:07 (after this PR). But I think it's at least *more* sound than a total revert :/

r? lcnr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

regression: crate compiles much slower with 1.82
7 participants