Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upSeparate impl items from the parent impl #37660
Conversation
rust-highfive
assigned
michaelwoerister
Nov 9, 2016
This comment has been minimized.
This comment has been minimized.
|
Hmm, had a thought last night. Another option that might make sense is to pull the Obviously, if we pursued the more aggressive strategy of rehashing partial results it sort of subsumes both cases. However, I remain somewhat nervous about that in the shorter term (though longer term it seems good). But also it seems advantageous to be able to determine as much as we can without having to re-run parts of the compiler. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis Maybe #37402 plus some dep node changes can solve that? |
This comment has been minimized.
This comment has been minimized.
|
@eddyb well, it seems to me that the current dep information is correct, unless we move the So fundamentally there are two ways to fix this:
It seems to me that for best results we want both. Having more precise information lets us quickly rule out work without even need to reconfirm. But at a certain point you get diminishing returns. Though perhaps the initial work to recompute signatures and so forth is cheap enough that it doesn't make sense to separate HIR more. I can easily believe that. I've talked about this with @michaelwoerister a fair amount. I tend to view this as "firewalls". That is, you have points where we hash the intermediate results because we can't (or don't care to) track the edges closely enough. The first example is from the files to the HIR. The second (existing) example is after trans collection. It makes sense to do it in more places, I suspect. Then in between these firewalls you can be conservative and just trace out the impact of a chance and invalidate the work in between said change and the next "firewall" (where you will want to re-hash). This will all fit very nicely with the work you are doing to make the compiler more demand-driven, of course, so I had hoped we could start moving more in that direction as that proceeds, but in short term get the HIR precise enough. (I still believe that.) |
This comment has been minimized.
This comment has been minimized.
That seems like a good idea to me. |
This comment has been minimized.
This comment has been minimized.
I also think that is true and as a consequence we should avoid doing any contortions in HIR representation just to improve dependency tracking. But the examples so far seem to make sense on their on right. |
michaelwoerister
reviewed
Nov 9, 2016
| @@ -974,9 +979,11 @@ fn check_impl_items_against_trait<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, | |||
| let trait_def = tcx.lookup_trait_def(impl_trait_ref.def_id); | |||
| let mut overridden_associated_type = None; | |||
|
|
|||
| let impl_items = || impl_item_ids.iter().map(|&id| ccx.tcx.map.impl_item(id)); | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
So, I did one pass looking through all the commits and I think it should indeed be merged. There are many good refactorings in it that make things cleaner, especially with respect to what's going on in |
This comment has been minimized.
This comment has been minimized.
|
@michaelwoerister so I just pushed a new commit intended to make the "nested" pattern a little more future-proof. This was mildly more tedious than I thought because it requires having better lifetime annotations to make it work (most visitors are written to accept a much wider range of lifetimes than is actually needed, since it winds up needing less explicit use of |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
I like it. It's a bit unfortunate with the additional lifetime annotations but not really a problem. |
alexcrichton
added
the
T-compiler
label
Nov 10, 2016
This comment has been minimized.
This comment has been minimized.
Sure, I can rename it. I'd prefer to leverage specialization to make a Also, I just pushed a PR that separates the name into the impl, which actually fixes the test cases that were blocked on this. |
nikomatsakis
force-pushed the
nikomatsakis:incremental-36349
branch
from
75a5c98
to
bd0a191
Nov 11, 2016
michaelwoerister
reviewed
Nov 11, 2016
| let name_and_namespace = |def_id| { | ||
| let item = self.tcx.associated_item(def_id); | ||
| let name_and_namespace = |r: &ty::AssociatedItemRef| { | ||
| let item = self.tcx.associated_item(r.def_id); |
This comment has been minimized.
This comment has been minimized.
michaelwoerister
Nov 11, 2016
Contributor
This is one of the cases where it would make sense to also store the kind of associated item in the ref.
This comment has been minimized.
This comment has been minimized.
eddyb
Nov 11, 2016
Member
I think I agree. I'd almost go as far as having associated_item use the DefId of its container for the dep node, and then just use associated_items everywhere.
This comment has been minimized.
This comment has been minimized.
I just looked through the new commits. Very nice |
This was referenced Nov 11, 2016
nikomatsakis
force-pushed the
nikomatsakis:incremental-36349
branch
4 times, most recently
from
acfac99
to
4fb31ca
Nov 11, 2016
This comment has been minimized.
This comment has been minimized.
|
@michaelwoerister @eddyb ready for re-review; I removed I think there is one thing missing from this PR before it can land though: we are not hashing all of the things in the |
This comment has been minimized.
This comment has been minimized.
|
Oh, I should add -- it didn't quite work as well as the old approach across crates, but I think that's a separate issue really. I filed #37720 describing it. |
This comment has been minimized.
This comment has been minimized.
|
|
eddyb
reviewed
Nov 12, 2016
| // for details. | ||
| ctp::setup_constraining_predicates(&mut ty_predicates.predicates, | ||
| trait_ref, | ||
| &mut ctp::parameters_for_impl(selfty, trait_ref)); |
This comment has been minimized.
This comment has been minimized.
eddyb
Nov 12, 2016
Member
Lovely! This might actually solve my trouble with this ordering thing, looks like it's self-contained now.
This comment has been minimized.
This comment has been minimized.
|
r=me with a rebase. |
nikomatsakis
force-pushed the
nikomatsakis:incremental-36349
branch
3 times, most recently
from
15209aa
to
9364fc2
Nov 14, 2016
nikomatsakis
added some commits
Nov 15, 2016
nikomatsakis
force-pushed the
nikomatsakis:incremental-36349
branch
from
ec345a3
to
ab79438
Nov 17, 2016
This comment has been minimized.
This comment has been minimized.
|
@bors r+ |
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors r=eddyb |
This comment has been minimized.
This comment has been minimized.
|
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
@bors r=eddyb |
This comment has been minimized.
This comment has been minimized.
|
|
nikomatsakis commentedNov 9, 2016
•
edited
This change separates impl item bodies out of the impl itself. This gives incremental more resolution. In so doing, it refactors how the visitors work, and cleans up a bit of the collect/check logic (mostly by moving things out of collect that didn't really belong there, because they were just checking conditions).
However, this is not as effective as I expected, for a kind of frustrating reason. In particular, when invoking
foo.bar()you still wind up with dependencies on private items. The problem is that the method resolution code scans that list for methods with the namebar-- and this winds up touching all the methods, even private ones.I can imagine two obvious ways to fix this:
So all in all I'm not quite sure whether to land this or not. =) It still seems like it has to be a win in some cases, but not with the test cases we have just now. I can try to gin up some test cases, but I'm not sure if they will be totally realistic. On the other hand, some of the early refactorings to the visitor trait seem worthwhile to me regardless.
cc #36349 -- well, this is basically a fix for that issue, I guess
r? @michaelwoerister
NB: Based atop of @eddyb's PR #37402; don't land until that lands.