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 upPartially implement RFC 1647 (`Self` in impl headers) #38920
Conversation
rust-highfive
assigned
nikomatsakis
Jan 8, 2017
This comment has been minimized.
This comment has been minimized.
|
FWIW I had solved the cycle problem a few months back (eddyb@204fdb2) and I'm planning to publish that as the next (and final?) PR after #38813. However I'm taking a (yet another) detour through doing lifetime elision syntactically (w/ name-resolved definitions but nothing based on type/trait resolution), which would allow a more efficient implementation of my fixpoint algorithm (it's backtracking atm so |
This comment has been minimized.
This comment has been minimized.
|
So do we want to wait here for some of @eddyb's work to land instead? |
This comment has been minimized.
This comment has been minimized.
|
@nikomatsakis |
petrochenkov
changed the title
[WIP] Implement RFC 1647 (`Self` in impl headers)
Partially implement RFC 1647 (`Self` in impl headers)
Jan 17, 2017
This comment has been minimized.
This comment has been minimized.
|
I'll rebase this tomorrow. |
petrochenkov
force-pushed the
petrochenkov:selfimpl
branch
from
4b8e39b
to
939368d
Jan 18, 2017
This comment has been minimized.
This comment has been minimized.
|
Rebased. |
petrochenkov
force-pushed the
petrochenkov:selfimpl
branch
from
939368d
to
f9bdf34
Jan 21, 2017
This comment has been minimized.
This comment has been minimized.
|
r? @eddyb -- he's been in this area so is best person to review |
rust-highfive
assigned
eddyb
and unassigned
nikomatsakis
Jan 25, 2017
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
added a commit
that referenced
this pull request
Jan 25, 2017
This comment has been minimized.
This comment has been minimized.
|
|
bors
merged commit f9bdf34
into
rust-lang:master
Jan 26, 2017
bluss
added
the
relnotes
label
Jan 28, 2017
eddyb
reviewed
Feb 2, 2017
| ty.subst(tcx, free_substs) | ||
|
|
||
| // FIXME: Self type is not always computed when we are here because type parameter | ||
| // bounds may affect Self type and have to be converted before it. |
This comment has been minimized.
This comment has been minimized.
eddyb
Feb 2, 2017
Member
I was working on the on-demand stuff and I just realized this can be made to work with AstConv::get_item_type.
In all fairness, ItemImpl is not hooked up to that in rustc_typeck::collect because of predicate complications, that are fixed on this branch I'm playing with (even if you can't get it from tcx.item_type, that's not needed here).
petrochenkov commentedJan 8, 2017
•
edited
The name resolution part is easy, but the typeck part contains an unexpected problem.
It turns out that
Selftype depends on bounds andwhereclauses, so we need to convert them first to determine what theSelftype is! If bounds/whereclauses can refer toSelfthen we have a cyclic dependency.This is required to support impls like this:
I'm not yet sure how to resolve this issue.
One possible solution (that feels hacky) is to make two passes over generics - first collect predicates ignoring everything involving
Self, then determineSelf, then collect predicates again without ignoring anything. (Some kind of lazy on-demand checking or something looks like a proper solution.)This patch in its current state doesn't solve the problem with
Selfin bounds, so the only observable things it does is improving error messages and supportingimpl Trait<Self> for Type {}.There's also a question about feature gating. It's non-trivial to detect "newly resolved"
Selfs to feature gate them, but it's simple to enable the new resolution behavior when the feature gate is already specified. Alternatively this can be considered a bug fix and merged without a feature gate.cc #38864
r? @nikomatsakis
cc @eddyb
Whitespace ignoring diff https://github.com/rust-lang/rust/pull/38920/files?w=1