Skip to content

Refactoring in support of generalized where clauses #19683

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 10 commits into from
Dec 13, 2014

Conversation

nikomatsakis
Copy link
Contributor

This patch does not itself enable generalized where clauses, but it lays the groundwork. Rather than storing a list of bounds per type parameter, the trait selection and other logic is now driven by a unified list of predicates. All predicate handling is now driven through a common interface. This also fixes a number of bugs where region predicates were being dropped on the floor. As a drive-by, this patch also fixes some bugs in the opt-out-copy feature flag.

That said, this patch does not change the parser or AST in any way, so we still generate the list of predicates by walking a list of bounds (and we still store the bounds on the TypeParameterDef and so on). Those will get patched in a follow-up.

The commits in this case are standalone; the first few are simple refactorings.

r? @nick29581
cc @aturon

@nikomatsakis nikomatsakis force-pushed the generalized-where-clauses branch from 1f3c13b to f2b770a Compare December 10, 2014 01:36
@sfackler
Copy link
Member

@nikomatsakis
Copy link
Contributor Author

D'oh! It seems that I left in a TODO that I meant to fix. I'll patch that up tomorrow -- forgot to implement part of metadata decoding (interesting that it didn't cause any tests to fail...)

@jroesch
Copy link
Member

jroesch commented Dec 10, 2014

This looks pretty good to me @nikomatsakis. I'm assuming this is the branch you were talking to me about earlier on IRC.

@jroesch
Copy link
Member

jroesch commented Dec 10, 2014

I just went to do a rebase of my changes on to master and it looks like it might be good to just wait and do it on top of these changes instead, there a few things important things that changed in the code, like the threading of the typing context lifetime through types like ty::Predicate<'tcx>, that would make it worth it.

@nikomatsakis
Copy link
Contributor Author

@jroesch yes, this is the branch.

@nikomatsakis
Copy link
Contributor Author

Regarding the TODO failure, I realize why all the tests pass -- the code as is basically omits instantiating the predicates vector for inlined code, but of course trans never even looks at the predicate vector. Still, it seems like asking for trouble to leave it as is -- though it's tempting since it will require touching metadata more deeply. >:(

@nikomatsakis
Copy link
Contributor Author

Sigh. I didn't run make check after the last rebase and now I'm seeing more substantial failures. Shouldn't require deep edits, but the branch as is won't build and run. I'll post a revised version soon.

@nikomatsakis nikomatsakis force-pushed the generalized-where-clauses branch from f2b770a to 8d63a57 Compare December 10, 2014 15:10
@nikomatsakis
Copy link
Contributor Author

OK, the problems turned out to be acrichto's patch

@nikomatsakis nikomatsakis force-pushed the generalized-where-clauses branch from 8d63a57 to b9ae8db Compare December 10, 2014 16:06
@nikomatsakis
Copy link
Contributor Author

Rebased. As of b9ae8db, make check is still running locally but is believed to pass.

@nikomatsakis
Copy link
Contributor Author

(I still didn't fix the annoying metadata issue though.)

@nikomatsakis nikomatsakis force-pushed the generalized-where-clauses branch from b9ae8db to 38a61f0 Compare December 10, 2014 18:46
@nikomatsakis
Copy link
Contributor Author

(OK, builds and passes make check locally now.)

selections: &mut Vec<Selection<'tcx>>,
errors: &mut Vec<FulfillmentError<'tcx>>,
region_obligations: &mut NodeMap<Vec<RegionObligation<'tcx>>>)
-> bool
Copy link
Member

Choose a reason for hiding this comment

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

THis might be clearer if it is called evaluate_predicate or something and returns the opposite of what it currently does - i.e., false if the predicate could not be evaluated right now and must be retained.

@nrc
Copy link
Member

nrc commented Dec 11, 2014

r=me, modulo minor comments

@nikomatsakis nikomatsakis force-pushed the generalized-where-clauses branch 3 times, most recently from ca38302 to 2f1d5d6 Compare December 11, 2014 09:46
in most cases, just the error message changed, but in some cases we
are reporting new errors that OUGHT to have been reported before but
we're overlooked (mostly involving the `'static` bound on `Send`).
@nikomatsakis nikomatsakis force-pushed the generalized-where-clauses branch from 2f1d5d6 to 124e1e1 Compare December 13, 2014 01:25
@nikomatsakis
Copy link
Contributor Author

Giving higher priority since this lays important groundwork for other patches for assoc types + unboxed closures

bors added a commit that referenced this pull request Dec 13, 2014
…=nrc

This patch does not itself enable generalized where clauses, but it lays the groundwork. Rather than storing a list of bounds per type parameter, the trait selection and other logic is now driven by a unified list of predicates. All predicate handling is now driven through a common interface. This also fixes a number of bugs where region predicates were being dropped on the floor. As a drive-by, this patch also fixes some bugs in the opt-out-copy feature flag.

That said, this patch does not change the parser or AST in any way, so we still *generate* the list of predicates by walking a list of bounds (and we still *store* the bounds on the `TypeParameterDef` and so on). Those will get patched in a follow-up.

The commits in this case are standalone; the first few are simple refactorings.

r? @nick29581 
cc @aturon
@bors bors closed this Dec 13, 2014
@bors bors merged commit 124e1e1 into rust-lang:master Dec 13, 2014
@nikomatsakis nikomatsakis deleted the generalized-where-clauses branch March 30, 2016 16:13
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.

6 participants