Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upImplement the new-style trait solver #56384
Conversation
rust-highfive
assigned
nikomatsakis
Nov 30, 2018
rust-highfive
added
the
S-waiting-on-review
label
Nov 30, 2018
This comment was marked as resolved.
This comment was marked as resolved.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
scalexm
force-pushed the
scalexm:chalk
branch
from
1cbf37f
to
eb4fa48
Nov 30, 2018
This comment has been minimized.
This comment has been minimized.
|
|
scalexm
force-pushed the
scalexm:chalk
branch
from
eb4fa48
to
ecc8604
Nov 30, 2018
This comment has been minimized.
This comment has been minimized.
|
The title of this PR is so epic |
This comment has been minimized.
This comment has been minimized.
|
|
scalexm
force-pushed the
scalexm:chalk
branch
from
ecc8604
to
f1b0eb4
Dec 8, 2018
nikomatsakis
requested changes
Dec 17, 2018
|
Sorry for being so slow @scalexm -- this looks great, but I do have a few concerns:
(Maybe we can only set the def-id if |
| ty::Infer(..) => { | ||
| // Everybody can find at least two types to unify against: | ||
| // general ty vars, int vars and float vars. | ||
| push_builtin_impl(tcx.types.i32, &[]); |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
Dec 17, 2018
Contributor
Hmm, this worries me. I feel like there could be cases where chalk is able to try out all 4 of those possibilities and conclude that something is true since because it doesn't know of the other Sized impls. But I see the challenge here, of course, in that to generate the "full set of sized impls" would in some sense require iterating over all the types in the system.
(This problem, though, doesn't seem entirely unique to sized)
I wonder if we should think about tweaking how the engine walks around this case. It's probably ok to land the code as is for now, but we likely want to add some sort of FIXME issue here to revisit this question specifically.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
scalexm
Dec 17, 2018
•
Member
Also I believe this problem is indeed not unique to Sized, but at least it would only show for traits that have built-in impls generated by the compiler. Other traits would be fine since we would be able to enumerate all the (user-written) impls.
| // `Set<T>` is an input type of `take_a_set`, hence we know that | ||
| // `T` must implement `Hash`, and we know in turn that `T` must | ||
| // implement `Eq`. | ||
| only_eq::<T>() |
This comment has been minimized.
This comment has been minimized.
nikomatsakis
added
S-waiting-on-author
and removed
S-waiting-on-review
labels
Dec 19, 2018
This comment has been minimized.
This comment has been minimized.
|
Current status to my knowledge: Waiting on @scalexm to rebase over the new version of chalk, at least, and perhaps to answer a few more of the questions above. |
scalexm
force-pushed the
scalexm:chalk
branch
from
f1b0eb4
to
3926994
Dec 20, 2018
This comment was marked as resolved.
This comment was marked as resolved.
|
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
scalexm
force-pushed the
scalexm:chalk
branch
from
3926994
to
9dab10d
Dec 20, 2018
nikomatsakis
approved these changes
Dec 27, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r+ I think it's a good idea to land this so we can iterate in tree |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Dec 27, 2018
This comment has been minimized.
This comment has been minimized.
|
This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again. How do I rebase?Assuming
You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial. Please avoid the "Resolve conflicts" button on GitHub. It uses Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Error message
|
bors
added
S-waiting-on-author
and removed
S-waiting-on-bors
labels
Dec 27, 2018
scalexm
added some commits
Nov 17, 2018
scalexm
added some commits
Nov 23, 2018
scalexm
force-pushed the
scalexm:chalk
branch
from
9dab10d
to
993d213
Dec 27, 2018
This comment has been minimized.
This comment has been minimized.
|
@bors r=nikomatsakis |
This comment has been minimized.
This comment has been minimized.
|
|
bors
added
S-waiting-on-bors
and removed
S-waiting-on-author
labels
Dec 27, 2018
This comment has been minimized.
This comment has been minimized.
added a commit
that referenced
this pull request
Dec 27, 2018
This comment has been minimized.
This comment has been minimized.
|
|
scalexm commentedNov 30, 2018
•
edited
Final PR of what I believe to be a minimally working implementation of the new-style trait solver.
The new trait solver can be used by providing the
-Z chalkcommand line flag. It is currently used everywhere inrustc_typeck, and for everything relying onrustc::infer::canonical::query_response::enter_canonical_trait_query.The trait solver is invoked in rustc by using the
evaluate_goalcanonical query. This is not optimal because each call toevaluate_goalcreates a newchalk_engine::Forest, hence rustc cannot use answers to intermediate goals produced by the root goal. We'll need to change that but I guess that's ok for now.Some next steps, I think, are:
chalk_engine(as a side effect, types or trait references with outlive requirements cannot be proved well-formed)-Z chalkin order to leverage the lazy normalization strategy of the new-style trait solverSizedis supported currently)I added a few very simple tests to check that the new solver has the right behavior, they won't be needed anymore once it is mature enough. Additionally it shows off that we get implied bounds for free.
r? @nikomatsakis