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

Do not cache ParamEnv candidates globally #94949

Conversation

compiler-errors
Copy link
Member

Fixes #94903

The issue here is that we're globally caching a trait selection result we get from the ParamEnv, specifically TraitPredicate(<SaveUser<ReErased> as StorageRequestReturnType>, polarity:Positive). Not sure where that erased bound comes from.

Not sure how to trigger this with a more structured test, but changing check-pass to build-pass triggers the case that #94903 detected.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Mar 15, 2022
@rust-highfive
Copy link
Collaborator

r? @petrochenkov

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 15, 2022
@petrochenkov
Copy link
Contributor

r? @Aaron1011 (you previously did something with this caching, IIRC)

@Aaron1011
Copy link
Member

This seems wrong - we include the ParamEnv in the global cache key, so it should be fine to store a ParamCandidate in the global cache.

@compiler-errors
Copy link
Member Author

compiler-errors commented Mar 15, 2022

Actually, you're right, this is wrong.

So the issue is that we're caching the predicate TraitPredicate(<SaveUser<ReErased> as StorageRequestReturnType>, polarity:Positive) with an empty RevealAll ParamEnv. Maybe we're erasing the regions from the predicate too early, and then it looks global when paired with ParamEnv::and (so it gets paired with an empty ParamEnv).

@compiler-errors
Copy link
Member Author

Anywho, I will take another look at this.

@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 Mar 15, 2022
@compiler-errors
Copy link
Member Author

Actually worked out a (possible?) bug in trait selection that fixes this issue instead.

@compiler-errors compiler-errors deleted the no-global-param-env-candidates branch April 7, 2022 04:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

ICE: failed to get layout for type, issue-80706.rs with --edition 2018
5 participants