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 unification routines #56214

Merged
merged 5 commits into from
Nov 30, 2018
Merged

Conversation

scalexm
Copy link
Member

@scalexm scalexm commented Nov 25, 2018

ResolventOps and AggregateOps are mostly straightforwardly translated from chalk. I had caught a few bugs already in my chalk branch and backported fixes to this branch, but there may be other ones left. EDIT: I hope there are none left now :)

Fixes #54935.

r? @nikomatsakis

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 25, 2018
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.

Everything seems fine except for the question of unifying two existential inference variables...

//! - This code uses "universes" to handle higher-ranked regions and
//! not the leak-check. This is "more correct" than what rustc does
//! and we are generally migrating in this direction, but NLL had to
//! get there first.
//!
//! Also, this code assumes that there are no bound type vars at all, not even
//! free ones. This is ok because:
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 not 100% sure what this means. For example, we might have for<'a> fn(&'a u32), right? That's a bound variable?

Copy link
Member Author

@scalexm scalexm Nov 29, 2018

Choose a reason for hiding this comment

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

no "bound type vars", so e.g. no for<T> ...

Copy link
Member Author

Choose a reason for hiding this comment

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

I replaced with "no bound types at all" (I dropped "vars")

src/librustc/infer/nll_relate/mod.rs Outdated Show resolved Hide resolved
src/librustc/infer/nll_relate/mod.rs Outdated Show resolved Hide resolved
@@ -340,7 +453,8 @@ where
a, b, self.ambient_variance
);

relate::super_relate_tys(self, a, b)
// Will also handle unification of `IntVar` and `FloatVar`.
self.infcx.super_combine_tys(self, a, b)
Copy link
Contributor

Choose a reason for hiding this comment

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

interesting. I guess that's ok. feels creepy to go into the "other" relate code but...

Copy link
Member Author

@scalexm scalexm Nov 29, 2018

Choose a reason for hiding this comment

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

I was thinking the same, but basically super_combine_tys just unifies int/float vars and calls super_relate_tys so...

self.universe,
universe
);
return Err(TypeError::Mismatch);
Copy link
Contributor

Choose a reason for hiding this comment

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

This surprises me. I don't think it is correct. In particular, unifying two unbound existential variables is infallible: it results in a unified variable whose universe is the minimum of the two universes, no? Am I misreading this?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes that's definitely a mistake

src/librustc_mir/borrow_check/nll/type_check/relate_tys.rs Outdated Show resolved Hide resolved
@rust-highfive

This comment has been minimized.

@rust-highfive

This comment has been minimized.

@nikomatsakis
Copy link
Contributor

@bors r+

@bors
Copy link
Contributor

bors commented Nov 29, 2018

📌 Commit 1fce415 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 Nov 29, 2018
@scalexm
Copy link
Member Author

scalexm commented Nov 29, 2018

@bors p=1
(I'm setting a priority because I'd like this to land quickly, as I'll be less available starting in December, if anybody has an issue with that please do contact me!)

@bors
Copy link
Contributor

bors commented Nov 30, 2018

⌛ Testing commit 1fce415 with merge 3dbe6bae99ecd6a2e6dd7a84ac603332d8ed678b...

@bors
Copy link
Contributor

bors commented Nov 30, 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 Nov 30, 2018
@rust-highfive
Copy link
Collaborator

The job dist-x86_64-linux-alt 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:50:08]     Finished dev [unoptimized + debuginfo] target(s) in 2m 59s
[01:50:08]   Installing /cargo/bin/cargo-vendor
[01:50:08] warning: be sure to add `/cargo/bin` to your PATH to be able to run the installed binaries
[01:50:12]  Downloading openssl-src v111.0.1+1.1.1
[01:50:52] warning: spurious network error (2 tries remaining): failed to download from `https://crates.io/api/v1/crates/openssl-src/111.0.1+1.1.1/download`
[01:51:32] warning: spurious network error (1 tries remaining): failed to download from `https://crates.io/api/v1/crates/openssl-src/111.0.1+1.1.1/download`
[01:52:18]  Downloading openssl-src v111.0.1+1.1.1
[01:52:58] warning: spurious network error (2 tries remaining): failed to download from `https://crates.io/api/v1/crates/openssl-src/111.0.1+1.1.1/download`
[01:53:38] warning: spurious network error (1 tries remaining): failed to download from `https://crates.io/api/v1/crates/openssl-src/111.0.1+1.1.1/download`
[01:54:18] 
[01:54:18] Caused by:
[01:54:18]   failed to fetch package
[01:54:18] 
[01:54:18] 
[01:54:18] Caused by:
[01:54:18]   unable to get packages from source
[01:54:18] 
[01:54:18] Caused by:
[01:54:18]   failed to download from `https://crates.io/api/v1/crates/openssl-src/111.0.1+1.1.1/download`
[01:54:18] Caused by:
[01:54:18]   [28] Timeout was reached
[01:54:18] 
[01:54:18] 
---
travis_time:end:06dbf69a:start=1543560158822313955,finish=1543560158832006520,duration=9692565
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00da24a3
$ 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 --batch -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:0195f6a4
travis_time:start:0195f6a4
$ 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:05b8591e
$ 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)

@scalexm
Copy link
Member Author

scalexm commented Nov 30, 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 Nov 30, 2018
@bors
Copy link
Contributor

bors commented Nov 30, 2018

⌛ Testing commit 1fce415 with merge 814805b8941fbf8ea2258a6b1c28c57a87fa00e9...

@bors
Copy link
Contributor

bors commented Nov 30, 2018

💔 Test failed - status-travis

@scalexm
Copy link
Member Author

scalexm commented Nov 30, 2018

@bors retry
I see a similar error in #55767 (comment)

@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 Nov 30, 2018
@bors
Copy link
Contributor

bors commented Nov 30, 2018

⌛ Testing commit 1fce415 with merge af2a8b786c99b3ec5e117c751ee95209c1334ef7...

@bors
Copy link
Contributor

bors commented Nov 30, 2018

💔 Test failed - status-appveyor

@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 Nov 30, 2018
@scalexm
Copy link
Member Author

scalexm commented Nov 30, 2018

@bors retry

#52590

---- net::tcp::tests::connect_timeout_unbound stdout ----
28706thread 'net::tcp::tests::connect_timeout_unbound' panicked at 'called Result::unwrap_err() on an Ok value: TcpStream { addr: V4(127.0.0.1:3856), peer: V4(127.0.0.1:3856), socket: 800 }', src\libcore\result.rs:1009:5

It seems like this PR will never land!

@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 Nov 30, 2018
@bors
Copy link
Contributor

bors commented Nov 30, 2018

⌛ Testing commit 1fce415 with merge 58d5ad432943e55fd60c1c548be00a5c625e70f9...

@bors
Copy link
Contributor

bors commented Nov 30, 2018

⌛ Testing commit 1fce415 with merge 8f1e94578a06f2c896a13d760c04904f70f881e3...

@scalexm
Copy link
Member Author

scalexm commented Nov 30, 2018

@bors p=0
In case it fails again, I’m giving back the priority to other PRs.

@bors
Copy link
Contributor

bors commented Nov 30, 2018

💔 Test failed - status-appveyor

@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 Nov 30, 2018
@scalexm
Copy link
Member Author

scalexm commented Nov 30, 2018

Same failure as in
#55011 (comment)

@kennytm
Copy link
Member

kennytm commented Nov 30, 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 Nov 30, 2018
kennytm added a commit to kennytm/rust that referenced this pull request Nov 30, 2018
Implement chalk unification routines

`ResolventOps` and `AggregateOps` are mostly straightforwardly translated from chalk. I had caught a few bugs already in my `chalk` branch and backported fixes to this branch, but there may be other ones left. EDIT: I hope there are none left now :)

Fixes rust-lang#54935.
bors added a commit that referenced this pull request Nov 30, 2018
Rollup of 19 pull requests

Successful merges:

 - #55011 (Add libstd Cargo feature "panic_immediate_abort")
 - #55821 (Use sort_by_cached_key when the key function is not trivial/free)
 - #56014 (add test for issue #21335)
 - #56131 (Assorted tweaks)
 - #56214 (Implement chalk unification routines)
 - #56216 (Add TryFrom<&[T]> for [T; $N] where T: Copy)
 - #56268 (Reuse the `P` in `InvocationCollector::fold_{,opt_}expr`.)
 - #56324 (Use raw_entry for more efficient interning)
 - #56336 (Clean up and streamline the pretty-printer)
 - #56337 (Fix const_fn ICE with non-const function pointer)
 - #56339 (Remove not used option)
 - #56341 (Rename conversion util; remove duplicate util in librustc_codegen_llvm.)
 - #56349 (rustc 1.30.0's linker flavor inference is a non-backwards compat change to -Clinker)
 - #56355 (Add inline attributes and add unit to CommonTypes)
 - #56360 (Optimize local linkchecker program)
 - #56364 (Fix panic with outlives in existential type)
 - #56365 (Stabilize self_struct_ctor feature.)
 - #56367 (Moved some feature gate tests to correct location)
 - #56373 (Update books)
@bors bors merged commit 1fce415 into rust-lang:master Nov 30, 2018
@scalexm scalexm deleted the unification branch February 4, 2019 14:30
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.

implement the ResolventOps methods for chalk integration
5 participants