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 associated existential types #52650

Merged
merged 4 commits into from
Jul 27, 2018

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 23, 2018

r? @nikomatsakis

no idea if these work with generic traits. I'm going home for the day 🤣

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 23, 2018
@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). 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.

[00:04:02] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:02] tidy error: /checkout/src/librustc/infer/anon_types/mod.rs:699: line longer than 100 chars
[00:04:04] some tidy checks failed
[00:04:04] 
[00:04:04] 
[00:04:04] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:04] 
[00:04:04] 
[00:04:04] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:04] Build completed unsuccessfully in 0:00:52
[00:04:04] Build completed unsuccessfully in 0:00:52
[00:04:04] make: *** [tidy] Error 1
[00:04:04] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:00d0eb38
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:1cc6f580:start=1532360864400677917,finish=1532360864413079365,duration=12401448
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:091cc914
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:03eea556
travis_time:start:03eea556
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:2b0ef3fa
$ dmesg | grep -i kill

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. (Feature Requests)

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.

Nice!

},
Some(hir::map::NodeImplItem(item)) => match item.node {
hir::ImplItemKind::Existential(_) => may_define_existential_type(
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess one of the wacky -- but perhaps .. fine -- consequences of this is that one could do something like

impl Foo for Bar {
    existential type Item;

    fn method() {
        fn helper() -> <Bar as Foo>::Item { .. }
    }

and that helper fn might count as a defining use?

I feel like we should only allow other members of the impl to be a defining use.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not allowing this kind of defining use would be inconsistent with how normal existential types work.

Copy link
Contributor

@nikomatsakis nikomatsakis Jul 25, 2018

Choose a reason for hiding this comment

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

I don't see it as particularly inconsistent — depends on your POV, I suppose. It seems to me that the various "sugared forms" (e.g., impl Trait) don't desugar directly to an existential type "sibling item", because they have different sets of defining uses... in the case of a function, only the fn return type in question. In the case of an impl, we get to decide?

For that matter, I do wonder if we would rather have the syntax here be type Item = impl Foo.

(cc @cramertj on this particular question)

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok landing either way, but I would want to open an unresolved question on this point

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea the syntax is horrible on purpose. It's the only one everyone could agree on that we do not want.

Copy link
Contributor

@nikomatsakis nikomatsakis Jul 25, 2018

Choose a reason for hiding this comment

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

I added two unresolved questions to the tracking issue. Dear god I hope they won't get lost. =)

Copy link
Member

Choose a reason for hiding this comment

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

IMO it's fine for helper to be a defining use of Item because it's "in the scope" of Item's definition (in this case, the trait impl).

Copy link
Contributor

Choose a reason for hiding this comment

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

Was there another discussion on syntax? Two points:

  • sometimes there are no constraints: but type Item; is of course ambiguous
  • "existential" is not really the correct term (mathematically it means "there exists at least one such ..."); really we just mean "indirectly specified"

So possibly indirect type Item; or unspec type Item; ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This implemented the placeholder syntax from the RFC. Please check out the discussion on the tracking issue and follow up RFCs. The syntax has been heavily discussed there and is currently being RFCed as type Item = impl Trait;. So if you disagree with the proposed syntax or otherwise have opinions on this topic, bring it up on that RFC.

}
let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
let ty = if let ty::AssociatedKind::Existential = assoc_ty.item.kind {
tcx.mk_anon(assoc_ty.item.def_id, substs)
Copy link
Contributor

Choose a reason for hiding this comment

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

huh, something looks fishy here -- you are using substs as part of ty in this case...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yea, I'm gonna add some generics tests and do this properly

} else {
tcx.type_of(assoc_ty.item.def_id)
};
let substs = translate_substs(selcx.infcx(), param_env, impl_def_id, substs, assoc_ty.node);
Progress {
ty: ty.subst(tcx, substs),

This comment was marked as resolved.

| (Type, Existential)
=> tcx.hygienic_eq(impl_item.ident, trait_item_name, trait_def_id),

_ => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd prefer to see this spelled out:

e.g., (Const, _) | (Method, _) | (Type, _) etc

this way when new kinds are added, we won't overlook them

@oli-obk oli-obk force-pushed the associated_existential_types branch from 65e016b to 01eacd8 Compare July 25, 2018 08:49
@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Jul 25, 2018

📌 Commit 33712a8 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-review Status: Awaiting review from the assignee but also interested parties. labels Jul 25, 2018
@bors
Copy link
Contributor

bors commented Jul 27, 2018

⌛ Testing commit 33712a8 with merge f1ecabf25ee6d7fc4a607e2e820013b8bf8619a1...

@bors
Copy link
Contributor

bors commented Jul 27, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 27, 2018
@rust-highfive
Copy link
Collaborator

The job dist-powerpc64le-linux of your PR failed on Travis (raw log). 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.
[01:46:26] [ 39%] Building MipsGenGlobalISel.inc...
[01:46:26] [ 39%] Building AArch64GenInstrInfo.inc...
[01:46:26] [ 39%] Building MipsGenInstrInfo.inc...

Broadcast message from root@travis-job-af0c6e06-6d69-43e8-bed8-f2f061e6472c
 (unknown) at 2:31 ...
The system is going down for power off NOW!
[01:46:27] 
[01:46:27] Session terminated, terminating shell...make[2]: make[2]: *** Deleting file `lib/Target/Mips/MipsGenGlobalISel.inc.tmp'
[01:46:27] *** Deleting file `lib/Target/X86/X86GenDAGISel.inc.tmp'
[01:46:27] make[2]: *** [lib/Target/Mips/MipsGenInstrInfo.inc.tmp] Terminatedmake[2]: *** [lib/Target/X86/X86GenDAGISel.inc.tmp] Terminated
[01:46:27] 
[01:46:27] make[1]: *** [lib/Target/X86/CMakeFiles/X86CommonTableGen.dir/all] Terminated
[01:46:27] make[1]: *** [lib/Target/Mips/CMakeFiles/MipsCommonTableGen.dir/all] Terminated
[01:46:27] make[2]: *** [lib/Target/AArch64/AArch64GenInstrInfo.inc.tmp] Terminated
[01:46:27] make[1]: *** [lib/Target/AArch64/CMakeFiles/AArch64CommonTableGen.dir/all] Terminated
[01:46:27]  ...terminated.
[01:46:27] make: *** [all] Terminated

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 143.
travis_time:start:1b968fa0
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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. (Feature Requests)

@kennytm
Copy link
Member

kennytm commented Jul 27, 2018

@bors retry

@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 Jul 27, 2018
@bors
Copy link
Contributor

bors commented Jul 27, 2018

⌛ Testing commit 33712a8 with merge c82d35770ac9d4b53bb93247456206c003c5e4e8...

@bors
Copy link
Contributor

bors commented Jul 27, 2018

💔 Test failed - status-travis

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jul 27, 2018
@rust-highfive
Copy link
Collaborator

The job dist-powerpc64le-linux of your PR failed on Travis (raw log). 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.
#######################################################                   77.6%
######################################################################## 100.0%
[00:01:27] extracting /checkout/obj/build/cache/2018-07-13/rust-std-beta-x86_64-unknown-linux-gnu.tar.gz
[00:01:28] downloading https://static.rust-lang.org/dist/2018-07-13/rustc-beta-x86_64-unknown-linux-gnu.tar.gz
No output has been received in the last 30m0s, this potentially indicates a stalled build or something wrong with the build itself.
Check the details on how to adjust your build configuration on: https://docs.travis-ci.com/user/common-build-problems/#Build-times-out-because-no-output-was-received
The build has been terminated

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. (Feature Requests)

@kennytm
Copy link
Member

kennytm commented Jul 27, 2018

@bors retry #40474

what is happening 😒

@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 Jul 27, 2018
@bors
Copy link
Contributor

bors commented Jul 27, 2018

⌛ Testing commit 33712a8 with merge 7c2aeb9...

bors added a commit that referenced this pull request Jul 27, 2018
…tsakis

Implement associated existential types

r? @nikomatsakis

no idea if these work with generic traits. I'm going home for the day 🤣
@bors
Copy link
Contributor

bors commented Jul 27, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: nikomatsakis
Pushing 7c2aeb9 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.

7 participants