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

Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering #66197

Merged
merged 9 commits into from Nov 15, 2019

Conversation

@Centril
Copy link
Member

Centril commented Nov 7, 2019

We currently have a hack in the form of ast::{ItemKind, ImplItemKind}::OpaqueTy which is constructed literally when you write type Alias = impl Trait; but not e.g. type Alias = Vec<impl Trait>;. Per rust-lang/rfcs#2515, this needs to change to allow impl Trait in nested positions. This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, TyKind::opaque_top_hack is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor

@bors

This comment was marked as resolved.

Copy link
Contributor

bors commented Nov 8, 2019

☔️ The latest upstream changes (presumably #66225) made this pull request unmergeable. Please resolve the merge conflicts.

@Centril Centril force-pushed the Centril:transparent-ast branch from 9ce6457 to 4ee926d Nov 9, 2019
ItemKind::TyAlias(ref ty, _) => {
let def_kind = match ty.kind.opaque_top_hack() {
None => DefKind::TyAlias,
Some(_) => DefKind::OpaqueTy,

This comment has been minimized.

Copy link
@petrochenkov

petrochenkov Nov 9, 2019

Contributor

So, I noticed today that DefKind::OpaqueTy and DefKind::AssocOpaqueTy exist despite the existential type syntax being removed.

Is it possible to remove them after this PR or it will require reworking lowering as well?

This comment has been minimized.

Copy link
@Centril

Centril Nov 10, 2019

Author Member

I'm not sure. We might need something like:

type Foo = (impl Bar, impl Baz); // In AST

=> (HIR)

opaque type _0: Bar; // DefKind::OpaqueTy
opaque type _1: Baz; // DefKind::OpaqueTy
type Foo = ( // DefKind::TyAlias
     _0, // TyKind::Def(..)
     _1 // TyKind::Def(..)
);

This comment has been minimized.

Copy link
@alexreg

alexreg Nov 10, 2019

Contributor

From my point of view: as long we still have something like opaque type in HIR still, that's good enough for my upcoming PR. I'd rather not remove that for a while yet.

This comment has been minimized.

Copy link
@varkor

varkor Nov 11, 2019

Member

We won't get rid of opaque types in HIR (they will always just arise from type aliases).

This comment has been minimized.

Copy link
@alexreg

alexreg Nov 11, 2019

Contributor

Yeah, that's what I thought. :-)

@bors

This comment was marked as resolved.

Copy link
Contributor

bors commented Nov 10, 2019

☔️ The latest upstream changes (presumably #65324) made this pull request unmergeable. Please resolve the merge conflicts.

@Centril Centril force-pushed the Centril:transparent-ast branch from 4ee926d to c43e4d1 Nov 11, 2019
@varkor

This comment has been minimized.

Copy link
Member

varkor commented Nov 11, 2019

Looks good to me, thanks!

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 11, 2019

📌 Commit c43e4d1 has been approved by varkor

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 13, 2019

⌛️ Testing commit c43e4d1 with merge a2ae41c...

bors added a commit that referenced this pull request Nov 13, 2019
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per rust-lang/rfcs#2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor
@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

rust-highfive commented Nov 13, 2019

The job x86_64-gnu-nopt of your PR failed (pretty log, 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.
2019-11-13T20:08:09.4648637Z 1 error: at least one trait must be specified
2019-11-13T20:08:09.4648936Z -   --> $DIR/generic_type_does_not_live_long_enough.rs:9:29
2019-11-13T20:08:09.4649187Z +   --> $DIR/generic_type_does_not_live_long_enough.rs:9:24
2019-11-13T20:08:09.4649250Z 3    |
2019-11-13T20:08:09.4649465Z 4 LL | type WrongGeneric<T> = impl 'static;
2019-11-13T20:08:09.4649743Z +    |                        ^^^^^^^^^^^^
2019-11-13T20:08:09.4649816Z 6 
2019-11-13T20:08:09.4649998Z 7 error[E0308]: mismatched types
2019-11-13T20:08:09.4650300Z 8   --> $DIR/generic_type_does_not_live_long_enough.rs:6:18
2019-11-13T20:08:09.4650300Z 8   --> $DIR/generic_type_does_not_live_long_enough.rs:6:18
2019-11-13T20:08:09.4650346Z 
2019-11-13T20:08:09.4650649Z 
2019-11-13T20:08:09.4650753Z The actual stderr differed from the expected stderr.
2019-11-13T20:08:09.4651183Z Actual stderr saved to /checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll/generic_type_does_not_live_long_enough.nll.stderr
2019-11-13T20:08:09.4651949Z To update references, rerun the tests and pass the `--bless` flag
2019-11-13T20:08:09.4652505Z To only update this specific test, also pass `--test-args type-alias-impl-trait/generic_type_does_not_live_long_enough.rs`
2019-11-13T20:08:09.4652780Z error: 1 errors occurred comparing output.
2019-11-13T20:08:09.4652872Z status: exit code: 1
2019-11-13T20:08:09.4652872Z status: exit code: 1
2019-11-13T20:08:09.4653969Z command: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "/checkout/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs" "-Zthreads=1" "--target=x86_64-unknown-linux-gnu" "--error-format" "json" "-Zui-testing" "-C" "prefer-dynamic" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll" "-Zborrowck=mir" "-Crpath" "-Cdebuginfo=0" "-Zunstable-options" "-Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.nll/auxiliary" "-A" "unused"
2019-11-13T20:08:09.4654934Z ------------------------------------------
2019-11-13T20:08:09.4655096Z 
2019-11-13T20:08:09.4655338Z ------------------------------------------
2019-11-13T20:08:09.4655524Z stderr:
2019-11-13T20:08:09.4655524Z stderr:
2019-11-13T20:08:09.4655756Z ------------------------------------------
2019-11-13T20:08:09.4655938Z error: at least one trait must be specified
2019-11-13T20:08:09.4656251Z   --> /checkout/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs:9:24
2019-11-13T20:08:09.4656505Z    |
2019-11-13T20:08:09.4656864Z LL | type WrongGeneric<T> = impl 'static;
2019-11-13T20:08:09.4657137Z 
2019-11-13T20:08:09.4657186Z error[E0308]: mismatched types
2019-11-13T20:08:09.4657600Z   --> /checkout/src/test/ui/type-alias-impl-trait/generic_type_does_not_live_long_enough.rs:6:18
2019-11-13T20:08:09.4657804Z    |
2019-11-13T20:08:09.4657804Z    |
2019-11-13T20:08:09.4657891Z LL |     let z: i32 = x; //~ ERROR mismatched types
2019-11-13T20:08:09.4657998Z    |                  ^ expected i32, found opaque type
2019-11-13T20:08:09.4658122Z    = note: expected type `i32`
2019-11-13T20:08:09.4658122Z    = note: expected type `i32`
2019-11-13T20:08:09.4658290Z               found type `WrongGeneric::<&{integer}>`
2019-11-13T20:08:09.4658584Z error: aborting due to 2 previous errors
2019-11-13T20:08:09.4658724Z 
2019-11-13T20:08:09.4662572Z For more information about this error, try `rustc --explain E0308`.
2019-11-13T20:08:09.4662689Z 
---
2019-11-13T20:08:09.4738772Z thread 'main' panicked at 'Some tests failed', src/tools/compiletest/src/main.rs:537:22
2019-11-13T20:08:09.4738941Z note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
2019-11-13T20:08:09.4753119Z 
2019-11-13T20:08:09.4753757Z 
2019-11-13T20:08:09.4765406Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/ui" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/ui" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "ui" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/checkout/obj/build/x86_64-unknown-linux-gnu/llvm/build/bin/FileCheck" "--host-rustcflags" "-Crpath -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--target-rustcflags" "-Crpath -Cdebuginfo=0 -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--llvm-version" "9.0.0-rust-1.41.0-dev\n" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always" "--compare-mode" "nll"
2019-11-13T20:08:09.4766543Z 
2019-11-13T20:08:09.4766596Z 
2019-11-13T20:08:09.4770278Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
2019-11-13T20:08:09.4770581Z Build completed unsuccessfully in 1:30:34
2019-11-13T20:08:09.4770581Z Build completed unsuccessfully in 1:30:34
2019-11-13T20:08:09.4827204Z == clock drift check ==
2019-11-13T20:08:09.4850113Z   local time: Wed Nov 13 20:08:09 UTC 2019
2019-11-13T20:08:09.6237849Z   network time: Wed, 13 Nov 2019 20:08:09 GMT
2019-11-13T20:08:09.6241620Z == end clock drift check ==
2019-11-13T20:08:10.7903743Z 
2019-11-13T20:08:10.8012724Z ##[error]Bash exited with code '1'.
2019-11-13T20:08:10.8048060Z ##[section]Starting: Checkout
2019-11-13T20:08:10.8050056Z ==============================================================================
2019-11-13T20:08:10.8050133Z Task         : Get sources
2019-11-13T20:08:10.8050218Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

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)

@bors

This comment was marked as resolved.

Copy link
Contributor

bors commented Nov 13, 2019

💔 Test failed - checks-azure

@Centril Centril force-pushed the Centril:transparent-ast branch from c43e4d1 to 03cf0d7 Nov 14, 2019
@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Nov 14, 2019

Ran ./x.py -i test src/test/ui --stage 1 --bless --pass check --compare-mode=nll

@bors r=varkor

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 14, 2019

📌 Commit 03cf0d7 has been approved by varkor

tmandry added a commit to tmandry/rust that referenced this pull request Nov 14, 2019
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per rust-lang/rfcs#2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor
bors added a commit that referenced this pull request Nov 14, 2019
Rollup of 8 pull requests

Successful merges:

 - #65557 (rename Error::iter_chain() and remove Error::iter_sources())
 - #66197 (Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering)
 - #66306 (Remove cannot mutate statics in initializer of another static error)
 - #66338 (Update mdbook.)
 - #66394 (Fix two OOM issues related to `ConstProp`)
 - #66396 (Make a test compatible across python versions.)
 - #66398 (Remove some stack frames from `.async` calls)
 - #66410 (miri: helper methods for max values of machine's usize/isize)

Failed merges:

r? @ghost
tmandry added a commit to tmandry/rust that referenced this pull request Nov 14, 2019
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per rust-lang/rfcs#2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor
bors added a commit that referenced this pull request Nov 14, 2019
Rollup of 9 pull requests

Successful merges:

 - #65557 (rename Error::iter_chain() and remove Error::iter_sources())
 - #66197 (Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering)
 - #66306 (Remove cannot mutate statics in initializer of another static error)
 - #66338 (Update mdbook.)
 - #66391 (Do not ICE in `if` without `else` in `async fn`)
 - #66396 (Make a test compatible across python versions.)
 - #66398 (Remove some stack frames from `.async` calls)
 - #66410 (miri: helper methods for max values of machine's usize/isize)
 - #66418 (Link to tracking issue in HIR const-check error code description)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 15, 2019

⌛️ Testing commit 03cf0d7 with merge 29095e1...

bors added a commit that referenced this pull request Nov 15, 2019
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per rust-lang/rfcs#2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor
Centril added a commit to Centril/rust that referenced this pull request Nov 15, 2019
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per rust-lang/rfcs#2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor
@Centril

This comment has been minimized.

Copy link
Member Author

Centril commented Nov 15, 2019

@bors retry rolled up.

bors added a commit that referenced this pull request Nov 15, 2019
Rollup of 5 pull requests

Successful merges:

 - #66197 (Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering)
 - #66415 (Add --force-run-in-process unstable option to libtest)
 - #66429 (Add a regression test for #62524)
 - #66435 (Correct `const_in_array_repeat_expressions` feature name)
 - #66443 (Port erased cleanup)

Failed merges:

r? @ghost
tmandry added a commit to tmandry/rust that referenced this pull request Nov 15, 2019
Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering

We currently have a hack in the form of `ast::{ItemKind, ImplItemKind}::OpaqueTy` which is constructed literally when you write `type Alias = impl Trait;` but not e.g. `type Alias = Vec<impl Trait>;`. Per rust-lang/rfcs#2515, this needs to change to allow `impl Trait` in nested positions.  This PR achieves this change for the syntactic aspect but not the semantic one, which will require changes in lowering and def collection. In the interim, `TyKind::opaque_top_hack` is introduced to avoid knock-on changes in lowering, collection, and resolve. These hacks can then be removed and fixed one by one until the desired semantics are supported.

r? @varkor
bors added a commit that referenced this pull request Nov 15, 2019
Rollup of 4 pull requests

Successful merges:

 - #66197 (Push `ast::{ItemKind, ImplItemKind}::OpaqueTy` hack down into lowering)
 - #66429 (Add a regression test for #62524)
 - #66435 (Correct `const_in_array_repeat_expressions` feature name)
 - #66443 (Port erased cleanup)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

bors commented Nov 15, 2019

⌛️ Testing commit 03cf0d7 with merge 1bd30ce...

@bors bors merged commit 03cf0d7 into rust-lang:master Nov 15, 2019
4 of 5 checks passed
4 of 5 checks passed
homu Testing commit 03cf0d737f075aa8839dd7cc5b1047910ec00ddf with merge 1bd30ce2aac40c7698aa4a1b9520aa649ff2d1c5...
Details
pr Build #20191114.35 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (Linux x86_64-gnu-tools) Linux x86_64-gnu-tools succeeded
Details
@Centril Centril deleted the Centril:transparent-ast branch Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.