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

Plumb inference obligations through selection #33301

Closed
wants to merge 2 commits into from

Conversation

soltanmm
Copy link

@soltanmm soltanmm commented May 1, 2016

An alternative to this implementation of plumbing is adding a nested field to the VtableObjectData and VtableFnPointer variants and dumping the inferred obligations right into the nested fields of the Vtable* types.

... And by 'alternative', given that I'm not familiar with the particulars of caching and how candidates and/or their bounds may or may not get invalidated or may or may no longer be obligated to fulfill a bound in the future, I mean: 'possibly correct implementation and what's currently in this PR is not only inefficient but outright awfully wrong'.

Next (in-parallel?) step is removing the consider_unification_despite_ambiguity in projection...

r? @nikomatsakis

Candidate assembly during selection should not affect the inference
context.
@bors
Copy link
Contributor

bors commented May 6, 2016

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


/// Obligations generated during inference. If None, no obligations are to be collected (e.g.
/// this is swapped out to a `None` when probing).
inferred_obligations: Option<PredicateObligations<'tcx>>
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, so I don't know how I feel about this field being in here. I feel like in the case of SelectionContext, because it doesn't represent a single atomic operation, it'd be better to just thread the obligations through explicitly, rather than collecting them into a vector stored in the selcx.

The need to swap this to None when probing, for example, feels like a warning sign to me: probing shouldn't have to swap anything, we should be able to just throw away the obligations if we don't want them.

OTOH, I can imagine that this is more efficient, since we'll probably create fewer "throw-away" vectors.

Copy link
Contributor

Choose a reason for hiding this comment

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

The last time I remember digging into this PR and trying to pull this field out and make the flow of obligations explicit, and it wound up leading me to problems in project.rs (the fix for this still hasn't landed; grr). So it might even be a bit hard to do this PR without those fixes having landed, or else we'd need to add more assert-is-empty points in project.rs.

Copy link
Author

Choose a reason for hiding this comment

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

What about using SnapshotVec? It's roughly the same principle (even using fewer allocs, perhaps), but: would that alleviate concerns w.r.t. the swapping?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. I might prefer SnapshotVec, yeah, coupled with some assertions
that the vector is empty each time we begin an operation. One thing that
worries me in the current setup is that we have None by default, so if
we forget to swap in a vec, things get dropped.

On Fri, May 06, 2016 at 03:11:31PM -0700, Masood Malekghassemi wrote:

@@ -78,8 +77,40 @@ pub struct SelectionContext<'cx, 'tcx:'cx> {
/// there is no type that the user could actually name that
/// would satisfy it. This avoids crippling inference, basically.
intercrate: bool,
+

  • /// Obligations generated during inference. If None, no obligations are to be collected (e.g.
  • /// this is swapped out to a None when probing).
  • inferred_obligations: Option<PredicateObligations<'tcx>>

What about using SnapshotVec? It's roughly the same principle (even using fewer allocs, perhaps), but: would that alleviate concerns w.r.t. the swapping?


You are receiving this because you were assigned.
Reply to this email directly or view it on GitHub:
https://github.com/rust-lang/rust/pull/33301/files/b7caae30c7389c3b92a8399577e007116c28f075..bf98976ec559d36f2aac16c1552155f417046afc#r62397872

Copy link
Author

Choose a reason for hiding this comment

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

A'ight, and do you have a preference between this PR and #33451? The basic gist of the difference is that this one has a SelectionOk ok-result while the other one puts the inferred obligations into the nested member of each Vtable* variant.

Copy link
Contributor

Choose a reason for hiding this comment

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

@soltanmm I'm not sure, been trying to find out on IRC, think we could sync up at some point?

@soltanmm
Copy link
Author

There'll be a new PR with a tweaked approach soon-ish.

@soltanmm soltanmm closed this May 12, 2016
@soltanmm soltanmm deleted the inquiry branch May 12, 2016 00:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants