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

[5/n] rustc: record the target type of every adjustment. #37408

Merged
merged 2 commits into from
Nov 6, 2016

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Oct 25, 2016

This is part of a series (prev | next) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. MIR-based early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments.


The first commit rearranges tcx.tables so that all users go through tcx.tables(). This in preparation for per-body Tables where they will be requested for a specific DefId. Included to minimize churn.

The rest of the changes focus on adjustments, there are some renamings, but the main addition is the target type, always available in all cases (as opposed to just for unsizing where it was previously needed).

Possibly the most significant effect of this change is that figuring out the final type of an expression is now always just one successful HashMap lookup (either the adjustment or, if that doesn't exist, the node type).

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

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

@bors
Copy link
Contributor

bors commented Oct 26, 2016

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

@eddyb eddyb force-pushed the lazy-5 branch 2 times, most recently from 8eb737b to 89a28f6 Compare October 27, 2016 01:52
@bors
Copy link
Contributor

bors commented Oct 27, 2016

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

@bors
Copy link
Contributor

bors commented Oct 29, 2016

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

@nikomatsakis
Copy link
Contributor

r=me

@eddyb
Copy link
Member Author

eddyb commented Nov 2, 2016

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Nov 2, 2016

📌 Commit 0d7201e has been approved by nikomatsakis

@bors
Copy link
Contributor

bors commented Nov 3, 2016

⌛ Testing commit 0d7201e with merge 09f94eb...

@bors
Copy link
Contributor

bors commented Nov 3, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton
Copy link
Member

@bors: retry

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Nov 4, 2016
[5/n] rustc: record the target type of every adjustment.

_This is part of a series ([prev](rust-lang#37404) | [next](rust-lang#37412)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https:/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

The first commit rearranges `tcx.tables` so that all users go through `tcx.tables()`. This in preparation for per-body `Tables` where they will be requested for a specific `DefId`. Included to minimize churn.

The rest of the changes focus on adjustments, there are some renamings, but the main addition is the target type, always available in all cases (as opposed to just for unsizing where it was previously needed).

Possibly the most significant effect of this change is that figuring out the final type of an expression is now _always_ just one successful `HashMap` lookup (either the adjustment or, if that doesn't exist, the node type).
@bors
Copy link
Contributor

bors commented Nov 5, 2016

⌛ Testing commit 0d7201e with merge d3b3b20...

@bors
Copy link
Contributor

bors commented Nov 5, 2016

💔 Test failed - auto-win-gnu-32-opt-rustbuild

@alexcrichton
Copy link
Member

@bors: retry

On Fri, Nov 4, 2016 at 5:43 PM, bors [email protected] wrote:

💔 Test failed - auto-win-gnu-32-opt-rustbuild
https://buildbot.rust-lang.org/builders/auto-win-gnu-32-opt-rustbuild/builds/2926


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#37408 (comment), or mute
the thread
https:/notifications/unsubscribe-auth/AAD95K3E-97LW8oOIi9FB_nEzsRJURJaks5q69FMgaJpZM4KgW57
.

@bors
Copy link
Contributor

bors commented Nov 5, 2016

⌛ Testing commit 0d7201e with merge 6c1c47f...

@bors
Copy link
Contributor

bors commented Nov 5, 2016

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented Nov 5, 2016

⌛ Testing commit 0d7201e with merge be724fc...

@bors
Copy link
Contributor

bors commented Nov 5, 2016

⛄ The build was interrupted to prioritize another pull request.

@bors
Copy link
Contributor

bors commented Nov 5, 2016

⌛ Testing commit 0d7201e with merge 884c93a...

@bors
Copy link
Contributor

bors commented Nov 5, 2016

💔 Test failed - auto-win-msvc-64-opt-rustbuild

@alexcrichton
Copy link
Member

@bors: retry

On Fri, Nov 4, 2016 at 10:19 PM, bors [email protected] wrote:

💔 Test failed - auto-win-msvc-64-opt-rustbuild
https://buildbot.rust-lang.org/builders/auto-win-msvc-64-opt-rustbuild/builds/2923


You are receiving this because you commented.
Reply to this email directly, view it on GitHub
#37408 (comment), or mute
the thread
https:/notifications/unsubscribe-auth/AAD95M5YPXS9DBPTJofJWbk3_myjpVNqks5q7BHrgaJpZM4KgW57
.

@bors
Copy link
Contributor

bors commented Nov 5, 2016

⌛ Testing commit 0d7201e with merge dce5eca...

@bors
Copy link
Contributor

bors commented Nov 5, 2016

💔 Test failed - auto-win-gnu-32-opt

bors added a commit that referenced this pull request Nov 5, 2016
bors added a commit that referenced this pull request Nov 6, 2016
@bors bors merged commit 0d7201e into rust-lang:master Nov 6, 2016
bors added a commit that referenced this pull request Nov 6, 2016
[4/n] rustc: harden against InferOk having obligations in more cases.

_This is part of a series ([prev](#37402) | [next](#37408)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https:/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

This adds more asserts that `InferOk` results have no obligations, pending completion of #32730.

Each of these could accidentally drop obligations on the floor if they start getting produced by unification, and a future change does just that, in order to produce a "shallow success" (hopefully leading to ambiguities during trait selection), _without_ the possibility of an eventual success - mostly guarded by ICEs for now.
@eddyb eddyb deleted the lazy-5 branch November 9, 2016 16:51
eddyb added a commit to eddyb/rust that referenced this pull request Nov 10, 2016
[6/n] rustc: transition HIR function bodies from Block to Expr.

_This is part of a series ([prev](rust-lang#37408) | [next](rust-lang#37676)) of patches designed to rework rustc into an out-of-order on-demand pipeline model for both better feature support (e.g. [MIR-based](https:/solson/miri) early constant evaluation) and incremental execution of compiler passes (e.g. type-checking), with beneficial consequences to IDE support as well.
If any motivation is unclear, please ask for additional PR description clarifications or code comments._

<hr>

The main change here is that functions and closures both use `Expr` instead of `Block` for their bodies.
For closures this actually allows a honest representation of brace-less closure bodies, e.g. `|x| x + 1` is now distinguishable from `|x| { x + 1 }`, therefore this PR is `[syntax-breaking]` (cc @Manishearth).

Using `Expr` allows more logic to be shared between constant bodies and function bodies, with some small such changes already part of this PR, and eventually easing rust-lang#35078 and per-body type tables.

Incidentally, there used to be some corners cut here and there and as such I had to (re)write divergence tracking for type-checking so that it is capable of understanding basic structured control-flow:

``` rust
fn a(x: bool) -> i32 {
    // match also works (as long as all arms diverge)
    if x { panic!("true") } else { return 1; }
    0 // "unreachable expression" after this PR
}
```

And since liveness' "not all control paths return a value" moved to type-checking we can have nice things:

``` rust
// before & after:
fn b() -> i32 { 0; } // help: consider removing this semicolon

// only after this PR
fn c() -> i32 { { 0; } } // help: consider removing this semicolon
fn d() { let x: i32 = { 0; }; } // help: consider removing this semicolon
fn e() { f({ 0; }); } // help: consider removing this semicolon
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants