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

Use a ParamEnvAnd<Predicate> for caching in ObligationForest #68475

Merged
merged 1 commit into from
Feb 15, 2020

Conversation

Aaron1011
Copy link
Member

Previously, we used a plain Predicate to cache results (e.g. successes
and failures) in ObligationForest. However, fulfillment depends on the
precise ParamEnv used, so this is unsound in general.

This commit changes the impl of ForestObligation for
PendingPredicateObligation to use ParamEnvAnd<Predicate> instead of
Predicate for the associated type. The associated type and method are
renamed from 'predicate' to 'cache_key' to reflect the fact that type is
no longer just a predicate.

@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 Jan 23, 2020
@Aaron1011
Copy link
Member Author

I don't have an example of unsound code that's current accepted due to this. However, I ran into this when working on a fix for #52843 - I attempted to register two Obligations with the same predicate but different ParamEnvs, but only one was ever fulfilled.

@rust-highfive

This comment has been minimized.

Previously, we used a plain `Predicate` to cache results (e.g. successes
and failures) in ObligationForest. However, fulfillment depends on the
precise `ParamEnv` used, so this is unsound in general.

This commit changes the impl of `ForestObligation` for
`PendingPredicateObligation` to use `ParamEnvAnd<Predicate>` instead of
`Predicate` for the associated type. The associated type and method are
renamed from 'predicate' to 'cache_key' to reflect the fact that type is
no longer just a predicate.
@petrochenkov
Copy link
Contributor

r? @nikomatsakis for review or reassignment

@Aaron1011
Copy link
Member Author

This could probably use a perf run, since it will cause fewer cache hits (though hopefully not significantly fewer).

@jonas-schievink
Copy link
Contributor

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Jan 25, 2020

⌛ Trying commit 90afc07 with merge a1a777c1499a6f109355684d92219c1afbf058f6...

@bors
Copy link
Contributor

bors commented Jan 25, 2020

☀️ Try build successful - checks-azure
Build commit: a1a777c1499a6f109355684d92219c1afbf058f6 (a1a777c1499a6f109355684d92219c1afbf058f6)

@rust-timer
Copy link
Collaborator

Queued a1a777c1499a6f109355684d92219c1afbf058f6 with parent 8ad83af, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit a1a777c1499a6f109355684d92219c1afbf058f6, comparison URL.

@Aaron1011
Copy link
Member Author

I think the syn-opt change is just noise, but I'm not certain.

@nikomatsakis
Copy link
Contributor

Will review soon, thanks @Aaron1011

@Aaron1011
Copy link
Member Author

@nikomatsakis: Are there any changes that you'd like me to make?

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

This is good, yes.

@nikomatsakis
Copy link
Contributor

Apologies for the long delay. This is a good PR, and actually an important step as part of the "move rustc closer to chalk goal", so .. great! The perf impacts look small, though I'm not sure on what basis we can declare them to be noise? But I hope you're right!

@bors r+

@bors
Copy link
Contributor

bors commented Feb 14, 2020

📌 Commit 90afc07 has been approved by nikomatsakis

@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 Feb 14, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Feb 14, 2020
…omatsakis

Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest`

Previously, we used a plain `Predicate` to cache results (e.g. successes
and failures) in ObligationForest. However, fulfillment depends on the
precise `ParamEnv` used, so this is unsound in general.

This commit changes the impl of `ForestObligation` for
`PendingPredicateObligation` to use `ParamEnvAnd<Predicate>` instead of
`Predicate` for the associated type. The associated type and method are
renamed from 'predicate' to 'cache_key' to reflect the fact that type is
no longer just a predicate.
bors added a commit that referenced this pull request Feb 14, 2020
Rollup of 7 pull requests

Successful merges:

 - #68129 (Correct inference of primitive operand type behind binary operation)
 - #68475 (Use a `ParamEnvAnd<Predicate>` for caching in `ObligationForest`)
 - #68856 (typeck: clarify def_bm adjustments & add tests for or-patterns)
 - #69051 (simplify_try: address some of eddyb's comments)
 - #69128 (Fix extra subslice lowering)
 - #69150 (Follow-up to #68848)
 - #69164 (Update pulldown-cmark dependency)

Failed merges:

r? @ghost
@bors bors merged commit 90afc07 into rust-lang:master Feb 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants