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

Add existential type definitions #51414

Merged
merged 7 commits into from
Jun 18, 2018
Merged

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 7, 2018

Note: this does not allow creating named existential types, it just desugars impl Trait to a less (but still very) hacky version of actual existential type items.

r? @nikomatsakis

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

The job x86_64-gnu-llvm-3.9 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:09:11]    Compiling syntax_ext v0.0.0 (file:///checkout/src/libsyntax_ext)
[00:09:26] error[E0308]: mismatched types
[00:09:26]     --> librustc/hir/lowering.rs:1192:38
[00:09:26]      |
[00:09:26] 1192 |                                 vis: hir::Visibility::Crate,
[00:09:26]      |                                      ^^^^^^^^^^^^^^^^^^^^^^ expected enum `hir::Visibility`, found fn item
[00:09:26]      = note: expected type `hir::Visibility`
[00:09:26]      = note: expected type `hir::Visibility`
[00:09:26]                 found type `fn(syntax::ast::CrateSugar) -> hir::Visibility {hir::Visibility::Crate}`
[00:09:47] error: aborting due to previous error
[00:09:47] 
[00:09:47] For more information about this error, try `rustc --explain E0308`.
[00:09:47] error: Could not compile `rustc`.
[00:09:47] error: Could not compile `rustc`.
[00:09:47] 
[00:09:47] Caused by:
[00:09:47]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc librustc/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=01e98699f9876faa -C extra-filename=-01e98699f9876faa --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps --target x86_64-unknown-linux-gnu -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps -L dependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/release/deps --extern flate2=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libflate2-5eb12204825df3be.rlib --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-6a2f0731783c2bd3.so --extern fmt_macros=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libfmt_macros-a1ad98118554e7d4.so --extern bitflags=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbitflags-99b4534960f92449.rlib --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-670f6bac60d99b34.so --extern lazy_static=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblazy_static-96c042dcc29a7e10.rlib --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-c9d6678b1c0f0b46.so --extern parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libparking_lot-210745eb40d9c073.rlib --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-58741ed9de9aae4f.so --extern rustc_data_structures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_data_structures-a7df2fc298b4fb06.so --extern rustc_rayon_core=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_rayon_core-6f8a066c77c355d9.rlib --extern proc_macro=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libproc_macro-524e4d04204f0089.so --extern chalk_engine=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libchalk_engine-dc5a2a01279da0f2.rlib --extern backtrace=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbacktrace-f3a2fb1d767a0bf7.rlib --extern scoped_tls=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libscoped_tls-b76c070114255d98.rlib --extern byteorder=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libbyteorder-78ebc049d4f53f46.rlib --extern graphviz=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libgraphviz-be994de8b3050feb.so --extern rustc_apfloat=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_apfloat-642a7efe79e24835.rlib --extern polonius_engine=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libpolonius_engine-6e0be5cf77966185.rlib --extern tempdir=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libtempdir-29f7cb771c179438.rlib --extern rustc_rayon=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_rayon-dc5c45209eae7e7b.rlib --extern jobserver=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libjobserver-e8a1df2f3ad631bc.rlib --extern arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-ccde2368d50449de.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-5073f1296cd24b67.rlib --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5d0a8a65bb9fe29f.so --extern serialize=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libserialize-5d0a8a65bb9fe29f.rlib -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-88673787176f9d86/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-62d80197b9ec531e/out` (exit code: 101)
[00:09:47] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "build" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "--message-format" "json"
[00:09:47] expected success, got: exit code: 101
[00:09:47] thread 'main' panicked at 'cargo must succeed', bootstrap/compile.rs:1091:9
[00:09:47] travis_fold:end:stage0-rustc

[00:09:47] travis_time:end:stage0-rustc:start=1528380373902319796,finish=1528380582318573618,duration=208416253822


[00:09:47] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:09:47] Build completed unsuccessfully in 0:03:42
[00:09:47] make: *** [all] Error 1
[00:09:47] Makefile:28: recipe for target 'all' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:032a729c
$ 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)

@oli-obk oli-obk force-pushed the impl_trait_type_def branch 2 times, most recently from 763eec8 to 065b7cb Compare June 7, 2018 15:33
@@ -284,7 +284,7 @@ pub fn change_return_impl_trait() -> impl Clone {
}

#[cfg(not(cfail1))]
#[rustc_clean(cfg = "cfail2", except = "Hir, HirBody")]
#[rustc_clean(cfg = "cfail2")]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

So this is the only change that I worry about. Not sure what's going on here. cc @michaelwoerister

Copy link
Member

Choose a reason for hiding this comment

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

did you ever get resolution as to why this change is necessary and whether it is safe to do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think the Hir is clean, because we now store just a NodeId and a DefId to the existential type declaration. If you change the trait of the impl Trait, those ids won't change. If changing the type of a type alias has the same effect on the incremental cache, then this change is fine, if not, then it's probably not fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Discussed this on irc https://botbot.me/mozilla/rustc/2018-06-18/?msg=101231153&page=1 his is fine as it is. The HIR does indeed not change anymore, but later queries will get retriggered because the HIR of the desugared existential type item has changed

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 7, 2018

cc @pnkfelix

@pnkfelix
Copy link
Member

pnkfelix commented Jun 7, 2018

r? @pnkfelix

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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:33:07]    Compiling aho-corasick v0.6.4
[00:33:13]    Compiling tempdir v0.3.7
[00:33:45]    Compiling minifier v0.0.11
[00:33:48]    Compiling rustdoc v0.0.0 (file:///checkout/src/librustdoc)
[00:33:54] error[E0609]: no field `bounds` on type `&rustc::hir::ItemId`
[00:33:54]     --> librustdoc/clean/mod.rs:2900:78
[00:33:54]      |
[00:33:54] 2900 |             TyImplTraitExistential(ref exist_ty, _, _) => ImplTrait(exist_ty.bounds.clean(cx)),
[00:33:54] 
[00:34:02] error: aborting due to previous error
[00:34:02] 
[00:34:02] For more information about this error, try `rustc --explain E0609`.
---
[00:34:02] 
[00:34:02] 
[00:34:02] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap build
[00:34:02] Build completed unsuccessfully in 0:29:22
[00:34:02] make: *** [all] Error 1
[00:34:02] Makefile:28: recipe for target 'all' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:05fd7208
$ 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)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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:45:56] .....i..............................................................................i...............
[00:46:01] ....................................................................................................
[00:46:07] ....................................................................................................
[00:46:13] ....................................................................................................
[00:46:18] .................i.................iiiiiiiii...................................................
[00:46:18] 
[00:46:18] travis_fold:start:test_ui_nll
travis_time:start:test_ui_nll
Check compiletest suite=ui mode=ui compare_mode=nll (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
---
[00:47:08] .....i..............................................................................i...............
[00:47:13] ....................................................................................................
[00:47:18] ....................................................................................................
[00:47:23] ....................................................................................................
[00:47:28] .................i.................iiiiiiiii...................................................
[00:47:28] 
[00:47:28]  finished in 70.443
[00:47:28] travis_fold:end:test_ui_nll

---
[01:22:06] travis_fold:start:test_stage1-rustc_driver
travis_time:start:test_stage1-rustc_driver
Testing rustc_driver stage1 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[01:22:06]    Compiling rustc_driver v0.0.0 (file:///checkout/src/librustc_driver)
[01:22:08] error[E0004]: non-exhaustive patterns: `ItemExistential(_)` not covered
[01:22:08]    --> librustc_driver/test.rs:250:26
[01:22:08] 250 |             return match it.node {
[01:22:08] 250 |             return match it.node {
[01:22:08]     |                          ^^^^^^^ pattern `ItemExistential(_)` not covered
[01:22:08] error: aborting due to previous error
[01:22:08] 
[01:22:08] For more information about this error, try `rustc --explain E0004`.
[01:22:08] error: Could not compile `rustc_driver`.
[01:22:08] error: Could not compile `rustc_driver`.
[01:22:08] 
[01:22:08] To learn more, run the command again with --verbose.
[01:22:08] 
[01:22:08] 
[01:22:08] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "-j" "4" "--release" "--locked" "--color" "always" "--features" " jemalloc" "--manifest-path" "/checkout/src/rustc/Cargo.toml" "-p" "rustc_driver" "--" "--quiet"
[01:22:08] 
[01:22:08] 
[01:22:08] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:22:08] Build completed unsuccessfully in 0:38:29
[01:22:08] Build completed unsuccessfully in 0:38:29
[01:22:08] make: *** [check] Error 1
[01:22:08] Makefile:58: recipe for target 'check' failed
34916 ./obj/build/x86_64-unknown-linux-gnu/native/jemalloc/src
34872 ./obj/build/x86_64-unknown-linux-gnu/test/run-pass
34588 ./obj/build/x86_64-unknown-linux-gnu/native/jemalloc/lib
34372 ./obj/build/x86_64-unknown-linux-gnu/doc/core/arch

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)

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 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:05:14] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:05:15] tidy error: /checkout/src/test/run-pass/impl-trait/bounds_regression.rs: missing trailing newline
[00:05:16] some tidy checks failed
[00:05:16] 
[00:05:16] 
[00:05:16] 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:05:16] 
[00:05:16] 
[00:05:16] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:16] Build completed unsuccessfully in 0:01:42
[00:05:16] Build completed unsuccessfully in 0:01:42
[00:05:16] make: *** [tidy] Error 1
[00:05:16] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:06e15b7d
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:10a3c5c4:start=1528874427842501595,finish=1528874427849687889,duration=7186294
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:11f23038
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:127cb460
$ 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)

@oli-obk oli-obk changed the title Add existential type definitons Add existential type definitions Jun 13, 2018
@pietroalbini
Copy link
Member

Ping from triage @pnkfelix! This PR needs your review.

@pnkfelix
Copy link
Member

@oli-obk this seems fine to me.

I now remember that @michaelwoerister may be out of contact for a little while. I'm personally okay with taking the risk of landing this even without having resolved the question of what is going on in that test you had to change.

So I'm going to tell bors to go ahead and land it.

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 18, 2018

📌 Commit adec1f9 has been approved by pnkfelix

@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 Jun 18, 2018
@bors
Copy link
Contributor

bors commented Jun 18, 2018

⌛ Testing commit adec1f9 with merge 862703e...

bors added a commit that referenced this pull request Jun 18, 2018
Add existential type definitions

Note: this does not allow creating named existential types, it just desugars `impl Trait` to a less (but still very) hacky version of actual `existential type` items.

r? @nikomatsakis
@bors
Copy link
Contributor

bors commented Jun 18, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: pnkfelix
Pushing 862703e to master...

@bors bors merged commit adec1f9 into rust-lang:master Jun 18, 2018
@oli-obk oli-obk deleted the impl_trait_type_def branch June 18, 2018 21:39
@nnethercote
Copy link
Contributor

This PR regressed the compile speed of the unused-warnings benchmark from rustc-perf, as shown by:
http://perf.rust-lang.org/compare.html?start=c45ae9ea3a9a073d7791de7ffc4f6762120602f5&end=862703e05e275d77b0b594bb5d1a26a6340933f2&stat=instructions:u

unused-warnings-check
        avg: 3.2%       min: 1.8%       max: 4.2%
unused-warnings
        avg: 2.6%       min: 1.3%       max: 3.6%
unused-warnings-opt
        avg: 2.5%       min: 1.3%       max: 3.5%

@oli-obk: Do you know why this might be? Can you investigate?

@nnethercote
Copy link
Contributor

CC @rust-lang/wg-compiler-performance

@@ -123,6 +123,11 @@ impl<'cx, 'gcx, 'tcx> TypeFolder<'gcx, 'tcx> for QueryNormalizer<'cx, 'gcx, 'tcx
let generic_ty = self.tcx().type_of(def_id);
let concrete_ty = generic_ty.subst(self.tcx(), substs);
self.anon_depth += 1;
if concrete_ty == ty {
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 sanity check is on a hot path. I'll change it to a debug assert

bors added a commit that referenced this pull request Jun 23, 2018
async/await

This PR implements `async`/`await` syntax for `async fn` in Rust 2015 and `async` closures and `async` blocks in Rust 2018 (tracking issue: #50547). Limitations: non-`move` async closures with arguments are currently not supported, nor are `async fn` with multiple different input lifetimes. These limitations are not fundamental and will be removed in the future, however I'd like to go ahead and get this PR merged so we can start experimenting with this in combination with futures 0.3.

Based on #51414.
cc @petrochenkov for parsing changes.
r? @eddyb
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