Skip to content
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

Implement Chalk lowering rule Normalize-From-Impl #49626

Merged
merged 5 commits into from
Apr 17, 2018

Conversation

fanzier
Copy link
Contributor

@fanzier fanzier commented Apr 3, 2018

This extends the Chalk lowering pass with the "Normalize-From-Impl" rule for generating program clauses from a trait definition as part of #49177.

r? @nikomatsakis

@fanzier
Copy link
Contributor Author

fanzier commented Apr 3, 2018

Note that this is my first real rustc contribution. So if I'm doing things wrong, let me know!

Also I wasn't sure how to test where clauses for associated types (WC1 in the rule). It seems like this (and GATs in general) are not fully implemented yet?

@nikomatsakis
Copy link
Contributor

@fanzier

Note that this is my first real rustc contribution. So if I'm doing things wrong, let me know!

Welcome! Sorry for me being slow! Still catching up from Rust All Hands.

@nikomatsakis
Copy link
Contributor

@fanzier

Also I wasn't sure how to test where clauses for associated types (WC1 in the rule). It seems like this (and GATs in general) are not fully implemented yet?

Yep. Still a WIP.

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Looks good! One nit.

@@ -171,6 +181,53 @@ fn program_clauses_for_impl<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId
Lrc::new(vec![clause])
}

pub fn program_clauses_for_associated_type<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, item_id: DefId)
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: can we make this for_associated_type_value or impl_item, something like that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point, changed it to type_value.

@nikomatsakis nikomatsakis added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 4, 2018
@TimNN
Copy link
Contributor

TimNN commented Apr 7, 2018

Your PR failed on Travis. Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
Resolving deltas: 100% (611592/611592), completed with 4857 local objects.
---
[00:00:55] configure: rust.quiet-tests     := True
---
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:046c5333:start=1523061092073389157,finish=1523061092080636946,duration=7247789
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:22b74af9
$ dmesg | grep -i kill
[   10.964306] init: failsafe main process (1092) killed by TERM signal

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 @TimNN.

@fanzier
Copy link
Contributor Author

fanzier commented Apr 7, 2018

The Travis failure seems to be spurious.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Apr 10, 2018

📌 Commit 2a18fdc has been approved by nikomatsakis

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 10, 2018
@kennytm
Copy link
Member

kennytm commented Apr 10, 2018

@bors r-

The log bot is still being tested, so don't rely entirely on it yet. The Travis failure is legit.

[00:23:22]    Compiling rustc_traits v0.0.0 (file:///checkout/src/librustc_traits)
[00:23:23] error[E0061]: this function takes 1 parameter but 2 parameters were supplied
[00:23:23]    --> librustc_traits/lowering.rs:226:18
[00:23:23]     |
[00:23:23] 226 |     let clause = Clause::Implies(where_clauses, normalize_goal);
[00:23:23]     |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 1 parameter
[00:23:23] 
[00:23:23] error: aborting due to previous error
[00:23:23] 
[00:23:23] error: Could not compile `rustc_traits`.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 10, 2018
@scalexm
Copy link
Member

scalexm commented Apr 10, 2018

Apart from the travis failure, seems mostly good, but there are some things which I think are not necessary, like adding the where clauses of the impl in the right hand side of Normalize(...) :- .... Anyway the PR introduces the Normalize domain goal, which was missing, so this is cool.

As for other rules related to associated types, I'd prefer to start by implementing all of them in chalk (not done yet, but they are fully described here ), and we'll probably revisit the rules in rustc one this has been done and proof tested in chalk.

@fanzier
Copy link
Contributor Author

fanzier commented Apr 11, 2018

@kennytm Good to know. I rebased and updated the code.

@scalexm I implemented the rule from the rustc guide (https://rust-lang-nursery.github.io/rustc-guide/traits-lowering-rules.html#lowering-impl-items). If I'm understanding you correctly, you're saying that the WC part of WC && WC1 is unnecessary. But if WC is not satisfied then the associated type doesn't exist because the trait is not implemented. What am I missing here?

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 11, 2018
@scalexm
Copy link
Member

scalexm commented Apr 11, 2018

@fanzier the rustc guide is not entirely up to date when it comes to associated types (especially because the rules have not been fully implemented and tested in chalk yet). I’m not sure yet if we want to assert that the trait is implemented in the Normalize predicate or somewhere else (especially because these where clauses have already been proved when typechecking the whole impl block). Anyway, let’s assume that we we would want this assertion in the Normalize predicate: then in that case, it would be better to have:

Normalize(<T as Trait>::AssocType -> U) :- Implemented(T: Foo) && WC1

rather than rewriting all the where clauses denoted by WC, i.e. we would juste « factorize » the where clauses into Implemented(T: Foo). I hope this makes sense :)

@fanzier
Copy link
Contributor Author

fanzier commented Apr 11, 2018

@scalexm Thanks for the explanation, that makes sense. I'll change it as you suggested.

@nikomatsakis
Copy link
Contributor

@bors delegate=scalexm

@bors
Copy link
Contributor

bors commented Apr 11, 2018

✌️ @scalexm can now approve this pull request

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 11, 2018
@bors bors added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 12, 2018
@kennytm
Copy link
Member

kennytm commented Apr 12, 2018

@bors retry rollup

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 12, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Apr 13, 2018
Implement Chalk lowering rule Normalize-From-Impl

This extends the Chalk lowering pass with the "Normalize-From-Impl" rule for generating program clauses from a trait definition as part of rust-lang#49177.

r? @nikomatsakis
@kennytm
Copy link
Member

kennytm commented Apr 13, 2018

@bors r- rollup-

Unfortunately #49800 has changed some types and caused this PR to fail. See #49939 (comment) for error log.

@bors bors added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 13, 2018
@fanzier
Copy link
Contributor Author

fanzier commented Apr 17, 2018

Can someone please approve this again? I only rebased and made it compile.

@scalexm
Copy link
Member

scalexm commented Apr 17, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Apr 17, 2018

📌 Commit b7c4a57 has been approved by scalexm

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Apr 17, 2018
@bors
Copy link
Contributor

bors commented Apr 17, 2018

⌛ Testing commit b7c4a57 with merge d703622...

bors added a commit that referenced this pull request Apr 17, 2018
Implement Chalk lowering rule Normalize-From-Impl

This extends the Chalk lowering pass with the "Normalize-From-Impl" rule for generating program clauses from a trait definition as part of #49177.

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Apr 17, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: scalexm
Pushing d703622 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants