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

52985 diagnostics no concrete type behind existential type #53588

Merged
merged 2 commits into from
Aug 23, 2018
Merged

52985 diagnostics no concrete type behind existential type #53588

merged 2 commits into from
Aug 23, 2018

Conversation

tristanburgess
Copy link
Contributor

@oli-obk FYI. See below for new cycle error generated.

error[E0391]: cycle detected when processing `Foo`
 --> /dev/staging/existential_type_no_concrete_type_nouse_potential.rs:3:1
  |
3 | existential type Foo: Copy;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: ...which requires processing `bar`...
 --> /dev/staging/existential_type_no_concrete_type_nouse_potential.rs:6:23
  |
6 |   fn bar(x: Foo) -> Foo { 
  |  _______________________^
7 | |     x
8 | | }
  | |_^
  = note: ...which again requires processing `Foo`, completing the cycle

error: aborting due to previous error

For more information about this error, try `rustc --explain E0391`.

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 22, 2018
@tristanburgess
Copy link
Contributor Author

tristanburgess commented Aug 22, 2018

@oli-obk, unrelated, but played around with some use cases for further testing and stumbled across some stuff. Let me know if you want me to move this message elsewhere. I have code snippets and corresponding errors, with expected behavior in comments on the snippets. Please let me know if my understanding is off; I based some assumptions off the documentation at https://github.com/rust-lang/rfcs/blob/master/text/2071-impl-trait-existential-types.md.

Would be happy to file issues for and potentially look further into some of these, though some of these issues may already be known. Wanted to just note them because I have a feeling that some of these cases working as described could invalidate or at least affect this PR.

1.
https://play.rust-lang.org/?gist=3dc99198be9127e774f231d9ebbfb519&version=nightly&mode=debug&edition=2015

2.
https://play.rust-lang.org/?gist=b543087e9c3371b3c8ab68b75e7bbb93&version=nightly&mode=debug&edition=2015

3.
https://play.rust-lang.org/?gist=81faea2f7e6fdb37d4d03564e56cc878&version=nightly&mode=debug&edition=2015

@oli-obk
Copy link
Contributor

oli-obk commented Aug 22, 2018

  1. yes we diverged from the RFC on purpose. Both for simplicity of the mental model and symmetry with impl Trait.
  2. same
  3. same

WRT this PR, does this mean we can revert your previous PR for this error?

@oli-obk
Copy link
Contributor

oli-obk commented Aug 22, 2018

I think rust-lang/rfcs#2515 is discussing the symmetry between impl Trait and existential type

@tristanburgess
Copy link
Contributor Author

tristanburgess commented Aug 22, 2018

@oli-obk agreed that we can revert the original PR as hitting the inf recursion case in normalize query would now be an unexpected occurrence, and likely should remain a bug! with the meaning that something should have detected what lead up to the infinite recursion case at an earlier time.

EDIT: I have reverted the relevant code from the original PR in commit a515eee below.

})
};

let old = self.tables.concrete_existential_types.insert(def_id, definition_ty);
if let ty::TyAnon(def_id, _substs) = definition_ty.sty {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should compare this def_id to the other def_id in scope and only run the type_of query if it is the same. Otherwise we're running it uselessly every time an existential type resolves to an existential type or an impl Trait type

Copy link
Contributor Author

@tristanburgess tristanburgess Aug 22, 2018

Choose a reason for hiding this comment

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

Worse, it would cause a cycle if you had an existential type that resolved to another TyAnon

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'll add a test case for this case

@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.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/4e/cf/0c313db4b8e3b231447d3807657db4f5e7fad26d5eaeb294b3cfa1388a6c/awscli-1.15.84-py2.py3-none-any.whl (1.3MB)
    0% |▎                               | 10kB 17.8MB/s eta 0:00:01
    1% |▌                               | 20kB 1.9MB/s eta 0:00:01
    2% |▊                               | 30kB 2.2MB/s eta 0:00:01
    3% |█                               | 40kB 2.0MB/s eta 0:00:01
---

[00:04:36] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:37] tidy error: /checkout/src/librustc_typeck/check/writeback.rs:495: trailing whitespace
[00:04:38] some tidy checks failed
[00:04:38] 
[00:04:38] 
[00:04:38] 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:38] 
[00:04:38] 
[00:04:38] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:38] Build completed unsuccessfully in 0:00:50
[00:04:38] Build completed unsuccessfully in 0:00:50
[00:04:38] Makefile:79: recipe for target 'tidy' failed
[00:04:38] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:0e40a296
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:1b481eab:start=1534974549838921867,finish=1534974549849600295,duration=10678428
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00676de2
$ 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:116db0be
travis_time:start:116db0be
$ 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:04b18861
$ 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)

@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.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/4e/cf/0c313db4b8e3b231447d3807657db4f5e7fad26d5eaeb294b3cfa1388a6c/awscli-1.15.84-py2.py3-none-any.whl (1.3MB)
    0% |▎                               | 10kB 12.9MB/s eta 0:00:01
    1% |▌                               | 20kB 1.9MB/s eta 0:00:01
    2% |▊                               | 30kB 2.2MB/s eta 0:00:01
    3% |█                               | 40kB 1.9MB/s eta 0:00:01
---
[00:13:09]    Compiling rustc_traits v0.0.0 (file:///checkout/src/librustc_traits)
[00:13:10] error[E0531]: cannot find tuple struct/variant `TyAnon` in module `ty`
[00:13:10]    --> librustc_typeck/check/writeback.rs:496:24
[00:13:10]     |
[00:13:10] 496 |             if let ty::TyAnon(defin_ty_def_id, _substs) = definition_ty.sty {
[00:13:10]     |                        ^^^^^^ did you mean `Anon`?
[00:13:15] error: aborting due to previous error
[00:13:15] 
[00:13:15] For more information about this error, try `rustc --explain E0531`.
[00:13:15] error: Could not compile `rustc_typeck`.
[00:13:15] error: Could not compile `rustc_typeck`.
[00:13:15] 
[00:13:15] Caused by:
[00:13:15]   process didn't exit successfully: `/checkout/obj/build/bootstrap/debug/rustc --crate-name rustc_typeck librustc_typeck/lib.rs --color always --error-format json --crate-type dylib --emit=dep-info,link -C prefer-dynamic -C opt-level=2 -C metadata=a0e39128708a13f4 -C extra-filename=-a0e39128708a13f4 --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 arena=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libarena-b8f9e6fb5ae336d7.so --extern log=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/liblog-b6c566856a1e65b9.rlib --extern rustc=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc-3a367afe0d047d15.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-8b624a6d6082b2ff.so --extern rustc_errors=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_errors-89eed8215142aadd.so --extern rustc_platform_intrinsics=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_platform_intrinsics-2e835ba951928190.so --extern rustc_target=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/librustc_target-20eb47b9c402fee3.so --extern syntax=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax-64bbe8e4870170a3.so --extern syntax_pos=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/deps/libsyntax_pos-3b51f50aecba154c.so -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/backtrace-sys-6c2cab36846647d7/out -L native=/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-rustc/x86_64-unknown-linux-gnu/release/build/miniz-sys-3c585aa15bfc4e69/out` (exit code: 1)

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)

  - Original cycle error diagnostics PR'd against this issue caught
panic-causing error while resolving std::mem::transmute calls
  - Now, catch invalid use case of not providing a concrete sized type
behind existential type in definining use case.
  - Update relevant test to reflect this new error

52985: revert normalize query changes
      - PR 53588 invalidates 53316, causing a correct cycle error to occur
    with a good span.
      - Don't need to revert the whole merge as the test files are
    still fine, just need to revert the normalize query changes.
      - It should now be correct that infinite recursion detected during
    normalize query type folding is a bug, should have been caught earlier
    (when resolving the existential type's defining use cases).

52985: code review impl
  - Only cause cycle error if anonymous type resolves to anonymous type
that has the same def id (is the same type) as the original (parent)
type.
  - Add test case to cover this case for existential types.

52985: remove Ty prefix from TyAnon
  - To align with changes per commit 6f637da
@oli-obk
Copy link
Contributor

oli-obk commented Aug 23, 2018

@bors r+

thanks!

@bors
Copy link
Contributor

bors commented Aug 23, 2018

📌 Commit 7440125 has been approved by oli-obk

@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 Aug 23, 2018
@bors
Copy link
Contributor

bors commented Aug 23, 2018

⌛ Testing commit 7440125 with merge 5ce5e08...

bors added a commit that referenced this pull request Aug 23, 2018
…ype_behind_existential_type, r=oli-obk

52985 diagnostics no concrete type behind existential type

@oli-obk FYI. See below for new cycle error generated.

```rust
error[E0391]: cycle detected when processing `Foo`
 --> /dev/staging/existential_type_no_concrete_type_nouse_potential.rs:3:1
  |
3 | existential type Foo: Copy;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
note: ...which requires processing `bar`...
 --> /dev/staging/existential_type_no_concrete_type_nouse_potential.rs:6:23
  |
6 |   fn bar(x: Foo) -> Foo {
  |  _______________________^
7 | |     x
8 | | }
  | |_^
  = note: ...which again requires processing `Foo`, completing the cycle

error: aborting due to previous error

For more information about this error, try `rustc --explain E0391`.
```
@bors
Copy link
Contributor

bors commented Aug 23, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: oli-obk
Pushing 5ce5e08 to master...

@bors bors merged commit 7440125 into rust-lang:master Aug 23, 2018
@tristanburgess tristanburgess deleted the 52985_diagnostics_no_concrete_type_behind_existential_type branch August 23, 2018 23:06
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.

5 participants