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

querify layout and move param env out of the infcx #42189

Merged
merged 8 commits into from
Jun 2, 2017

Conversation

nikomatsakis
Copy link
Contributor

The main goal of this PR is to move the parameter environment out of the inference context. This is because the inference environment will soon be changing over the course of inference --- for example, when we enter into a for<'a> fn(...) type, we will push a new environment with an increasing universe index, rather than skolemizing the 'a references. Similarly, each obligation will soon be able to have a distinct parameter environment, and therefore the Obligation struct is extended to carry a ParamEnv<'tcx>. (I debated about putting it into the cause; seems plausible, but also weird.)

Along the way, I also reworked how layout works, moving the layout cache into a proper query along the lines of needs-drop and friends.

Finally, tweaks the inference context API. It seemed to be accumulating parameters at an alarming rate. The main way to e.g. make a subtype or equality relationship is to do the following:

infcx.at(cause, param_env).sub(a, b)
infcx.at(cause, param_env).eq(a, b)

In both cases, a is considered the "expected" type (this used to be specified by a boolean). I tried hard to preserve the existing notion of what was "expected", although in some cases I'm not convinced it was being set on purpose one way or the other. This is why in some cases you will see me do sup(b, a), which is otherwise equivalent to sub(a, b), but sets the "expected type" differently.

r? @eddyb
cc @arielb1

@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 24, 2017
let type_desc = format!("{:?}", ty);
let overall_size = layout.size(tcx);
let align = layout.align(tcx);
tcx.sess.code_stats.borrow_mut().record_type_size(kind,
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit of a hack but I can live with impure stats just like we have diagnostics.

@eddyb
Copy link
Member

eddyb commented May 25, 2017

@bors r+

@bors
Copy link
Contributor

bors commented May 25, 2017

📌 Commit 629812d has been approved by eddyb

@bors
Copy link
Contributor

bors commented May 26, 2017

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

@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented May 26, 2017

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented May 26, 2017

📌 Commit 629812d has been approved by eddyb

@nikomatsakis nikomatsakis force-pushed the chalk-trait-env-param-env branch from 629812d to 5977dc3 Compare May 26, 2017 19:16
@Mark-Simulacrum
Copy link
Member

@bors r-

Should be a quick fix, this is just the UI tests updating due to no longer being counted:

[01:08:42] diff of stderr:
[01:08:42] 
[01:08:42]  error[E0391]: unsupported cyclic reference between types/traits detected
[01:08:42]    |
[01:08:42]  note: the cycle begins when computing layout of `S`...
[01:08:42]  note: ...which then requires computing layout of `std::option::Option<<S as Mirror>::It>`...
[01:08:42]  note: ...which then requires computing layout of `<S as Mirror>::It`...
[01:08:42]    = note: ...which then again requires computing layout of `S`, completing the cycle.
[01:08:42]  
[01:08:42] -error: aborting due to previous error
[01:08:42] +error: aborting due to previous error(s)
[01:08:42]  
[01:08:42] 
[01:08:42] The actual stderr differed from the expected stderr.
[01:08:42] 
[01:08:42] ------------------------------------------
[01:08:42] stderr:
[01:08:42] ------------------------------------------
[01:08:42] error[E0391]: unsupported cyclic reference between types/traits detected
[01:08:42]   |
[01:08:42] note: the cycle begins when computing layout of `S`...
[01:08:42] note: ...which then requires computing layout of `std::option::Option<<S as Mirror>::It>`...
[01:08:42] note: ...which then requires computing layout of `<S as Mirror>::It`...
[01:08:42]   = note: ...which then again requires computing layout of `S`, completing the cycle.
[01:08:42] 
[01:08:42] error: aborting due to previous error(s)
[01:08:42] 
[01:08:42] ------------------------------------------
[01:08:42] 
[01:08:42] thread '[ui] ui/issue-26548.rs' panicked at 'explicit panic', /checkout/src/tools/compiletest/src/runtest.rs:2472
[01:08:42] failures:
[01:08:42]     [ui] ui/issue-26548.rs

@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented May 27, 2017

📌 Commit 9b6baa5 has been approved by eddyb

@Mark-Simulacrum Mark-Simulacrum 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 May 28, 2017
@bors
Copy link
Contributor

bors commented May 28, 2017

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

@carols10cents carols10cents added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels May 29, 2017
@bors
Copy link
Contributor

bors commented May 30, 2017

🔒 Merge conflict

@nikomatsakis nikomatsakis force-pushed the chalk-trait-env-param-env branch from 9b6baa5 to 62e4733 Compare May 30, 2017 14:10
@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented May 30, 2017

📌 Commit 62e4733 has been approved by eddyb

@bors
Copy link
Contributor

bors commented May 30, 2017

⌛ Testing commit 62e4733 with merge 8b63d0b...

bors added a commit that referenced this pull request May 30, 2017
querify layout and move param env out of the infcx

The main goal of this PR is to move the parameter environment *out* of the inference context. This is because the inference environment will soon be changing over the course of inference --- for example, when we enter into a `for<'a> fn(...)` type, we will push a new environment with an increasing universe index, rather than skolemizing the `'a` references. Similarly, each obligation will soon be able to have a distinct parameter environment, and therefore the `Obligation` struct is extended to carry a `ParamEnv<'tcx>`. (I debated about putting it into the cause; seems plausible, but also weird.)

Along the way, I also reworked how layout works, moving the layout cache into a proper query along the lines of needs-drop and friends.

Finally, tweaks the inference context API. It seemed to be accumulating parameters at an alarming rate. The main way to e.g. make a subtype or equality relationship is to do the following:

    infcx.at(cause, param_env).sub(a, b)
    infcx.at(cause, param_env).eq(a, b)

In both cases, `a` is considered the "expected" type (this used to be specified by a boolean). I tried hard to preserve the existing notion of what was "expected", although in some cases I'm not convinced it was being set on purpose one way or the other. This is why in some cases you will see me do `sup(b, a)`, which is otherwise equivalent to `sub(a, b)`, but sets the "expected type" differently.

r? @eddyb
cc @arielb1
@bors
Copy link
Contributor

bors commented May 30, 2017

💔 Test failed - status-travis

@Mark-Simulacrum
Copy link
Member

@bors retry

  • Travis timed out after 6+ hours due to current problems, I hope this might indicate they've started to be resolved.

@nikomatsakis nikomatsakis 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 31, 2017
@bors
Copy link
Contributor

bors commented Jun 1, 2017

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

@nikomatsakis nikomatsakis force-pushed the chalk-trait-env-param-env branch from 62e4733 to 952bc4b Compare June 1, 2017 15:18
@nikomatsakis
Copy link
Contributor Author

tfw you rebase something and, by the time you're done, there's another conflict

@nikomatsakis nikomatsakis force-pushed the chalk-trait-env-param-env branch from 952bc4b to 84047db Compare June 1, 2017 17:31
@nikomatsakis
Copy link
Contributor Author

@bors r=eddyb

@bors
Copy link
Contributor

bors commented Jun 1, 2017

📌 Commit 84047db has been approved by eddyb

@bors
Copy link
Contributor

bors commented Jun 2, 2017

⌛ Testing commit 84047db with merge 107bd67...

bors added a commit that referenced this pull request Jun 2, 2017
querify layout and move param env out of the infcx

The main goal of this PR is to move the parameter environment *out* of the inference context. This is because the inference environment will soon be changing over the course of inference --- for example, when we enter into a `for<'a> fn(...)` type, we will push a new environment with an increasing universe index, rather than skolemizing the `'a` references. Similarly, each obligation will soon be able to have a distinct parameter environment, and therefore the `Obligation` struct is extended to carry a `ParamEnv<'tcx>`. (I debated about putting it into the cause; seems plausible, but also weird.)

Along the way, I also reworked how layout works, moving the layout cache into a proper query along the lines of needs-drop and friends.

Finally, tweaks the inference context API. It seemed to be accumulating parameters at an alarming rate. The main way to e.g. make a subtype or equality relationship is to do the following:

    infcx.at(cause, param_env).sub(a, b)
    infcx.at(cause, param_env).eq(a, b)

In both cases, `a` is considered the "expected" type (this used to be specified by a boolean). I tried hard to preserve the existing notion of what was "expected", although in some cases I'm not convinced it was being set on purpose one way or the other. This is why in some cases you will see me do `sup(b, a)`, which is otherwise equivalent to `sub(a, b)`, but sets the "expected type" differently.

r? @eddyb
cc @arielb1
@bors
Copy link
Contributor

bors commented Jun 2, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing 107bd67 to master...

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.

6 participants