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 up🔬 implement "always applicable impls" #48538
Comments
nikomatsakis
added
T-compiler
WG-compiler-traits
E-needs-mentor
labels
Feb 25, 2018
nikomatsakis
referenced this issue
Feb 25, 2018
Open
Tracking issue for specialization (RFC 1210) #31844
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis I would like to take this since it's related to specialization, which is the topic I've covered the most. Months ago I wrote a tracking issue (#45982) pointing out the things to do related to "restrictions around lifetime dispatch". |
This comment has been minimized.
This comment has been minimized.
|
@giannicic sounds about right, yes. |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis
Could work? |
giannicic
self-assigned this
Mar 1, 2018
This comment has been minimized.
This comment has been minimized.
|
@giannicic Sorry for the delay. PS, feel free to reach out on gitter as well.
I don't think that's necessary, but it seems ok to start there. I agree we want both eventually. It might also be better to wait on the "always applicable" side of the equation until we've made more progress around the chalk-ification process etc.
Hmm, I don't know that I agree with that proposed change. I think That logic is presently handled here, when constructing the specialization graph. You can see that in the event of overlap it checks whether either of the two impls specialize one another: rust/src/librustc/traits/specialize/specialization_graph.rs Lines 141 to 154 in 0ff9872 I'm not entirely sure how best to extend this logic to intersection impls though. It seems like we need to start constructing a more complex graph? Maybe I'm overthinking it, but I am imagining something like adding all the impls to a graph, then adding "overlaps" and "specialized by" edges where applicable (note that "specialized by" implies "overlap"). So e.g. the classic "intersection" case might look like:
If we insert a synthetic "bottom" -- basically, an empty impl that hence specializes all others -- then we can say that impls A and B are allowed to overlap if their immediate, mutual postdominator in the graph is not the "bottom impl". Moreover, that postdominator is the specializing impl (in this case, C). Note that we have a postdominator computation in Thinking about this a bit more, I guess we just need to compute the "specialized by" edges -- we may not need to "materialize" the overlaps edges, though we probably want to keep a list for later reference of things that overlapped but did not specialize (so we can check that they have a mutual postdominator). Does that make some sense? |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
Status update.
Inserting multiple parent implies that each possible impl must be visited in order to find the parents of a given impl. So the insert method should return a Then the overlap error can no more be triggered at insertion time but should be checked once the graph is fully build. I'll use the overlap edges in order to check for overlapping errors. @nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
@giannicic this looks roughly right. I suspect we don't need to store the overlap edges in the graph -- after all, I think we only need them during overlap checking. We could keep a set of pairs instead. Regarding whether to store in "both directions", I would instead canonicalize the def-ids so that the "lower" one appears first, since you don't really need to store both directions. |
nikomatsakis commentedFeb 25, 2018
Part of #31844: In order to eventually stabilize specialization, we need to make it sound. The current plan for doing so is called "always applicable impls", and is explained in this blog post. This issue exists to track the implementation of that proposal.
This does not yet have any mentoring instructions. Ping me if you are interested though and we can talk it over! Or maybe I'll get to it before then.