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

rustc_target: pass contexts by reference, not value. #55665

Merged
merged 1 commit into from
Nov 4, 2018

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Nov 3, 2018

LayoutOf now takes &self instead of self, and so does every method generic over a context that implements LayoutOf and/or other traits, like HasDataLayout, HasTyCtxt, etc.

Originally using by-value Copy types was relevant because TyCtxt was one of those types, but now TyCtxt::layout_of is separate from LayoutOf, and TyCtxt is not an often used layout context.

Passing these context by reference is a lot nicer for miri, which has self: &mut EvalContext, and needed f(&self) (that is, creating &&mut EvalContext references) for layout purposes.
Now, the &mut EvalContext can be passed to a function expecting &C, directly.

This should help with #54012 / #55627 (to not need where &'a T::Cx: LayoutOf bounds).

r? @nikomatsakis or @oli-obk or @nagisa cc @sunfishcode

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Nov 3, 2018
src/librustc_lint/types.rs Show resolved Hide resolved
src/librustc_mir/hair/cx/mod.rs Show resolved Hide resolved
src/librustc_mir/interpret/cast.rs Outdated Show resolved Hide resolved
@oli-obk
Copy link
Contributor

oli-obk commented Nov 3, 2018

@bors r+

@bors
Copy link
Contributor

bors commented Nov 3, 2018

📌 Commit d42d783863bda3a192e32e7c89d7779b4a76b093 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 Nov 3, 2018
@bors
Copy link
Contributor

bors commented Nov 4, 2018

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

@bors bors 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 Nov 4, 2018
@eddyb
Copy link
Member Author

eddyb commented Nov 4, 2018

@bors r=oli-obk p=1 (blocking #55627 which bitrots fast)

@bors
Copy link
Contributor

bors commented Nov 4, 2018

📌 Commit d00d42d 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-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Nov 4, 2018
@bors
Copy link
Contributor

bors commented Nov 4, 2018

⌛ Testing commit d00d42d with merge e6c5cf9...

bors added a commit that referenced this pull request Nov 4, 2018
rustc_target: pass contexts by reference, not value.

`LayoutOf` now takes `&self` instead of `self`, and so does every method generic over a context that implements `LayoutOf` and/or other traits, like `HasDataLayout`, `HasTyCtxt`, etc.

Originally using by-value `Copy` types was relevant because `TyCtxt` was one of those types, but now `TyCtxt::layout_of` is separate from `LayoutOf`, and `TyCtxt` is not an often used layout context.

Passing these context by reference is a lot nicer for miri, which has `self: &mut EvalContext`, and needed `f(&self)` (that is, creating `&&mut EvalContext` references) for layout purposes.
Now, the `&mut EvalContext` can be passed to a function expecting `&C`, directly.

This should help with #54012 / #55627 (to not need `where &'a T::Cx: LayoutOf` bounds).

r? @nikomatsakis or @oli-obk or @nagisa cc @sunfishcode
@bors
Copy link
Contributor

bors commented Nov 4, 2018

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

@bors bors merged commit d00d42d into rust-lang:master Nov 4, 2018
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #55665!

Tested on commit e6c5cf9.
Direct link to PR: #55665

💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 clippy-driver on linux: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 rls on windows: test-pass → build-fail (cc @nrc @Xanewok, @rust-lang/infra).
💔 rls on linux: test-pass → build-fail (cc @nrc @Xanewok, @rust-lang/infra).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Nov 4, 2018
Tested on commit rust-lang/rust@e6c5cf9.
Direct link to PR: <rust-lang/rust#55665>

💔 clippy-driver on windows: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 clippy-driver on linux: test-pass → build-fail (cc @Manishearth @llogiq @mcarton @oli-obk, @rust-lang/infra).
💔 rls on windows: test-pass → build-fail (cc @nrc @Xanewok, @rust-lang/infra).
💔 rls on linux: test-pass → build-fail (cc @nrc @Xanewok, @rust-lang/infra).
matthiaskrgr added a commit to matthiaskrgr/rust-clippy that referenced this pull request Nov 4, 2018
bors bot added a commit to rust-lang/rust-clippy that referenced this pull request Nov 4, 2018
3411: rustup rust-lang/rust#55665 (pass contexts by reference) r=matthiaskrgr a=matthiaskrgr



Co-authored-by: Matthias Krüger <matthias.krueger@famsik.de>
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Nov 4, 2018
Fixes clippy toolstate.

Changes:

````
rustup rust-lang#55665 (pass contexts by reference)
Fix typo
Improve clippy_dev help text
RIIR update lints: Generate lint group registrations
Test clippy_dev on CI and fix test
RIIR update lints: Generate modules section
````
@eddyb eddyb deleted the by-ref-layout-of branch November 4, 2018 23:22
bors added a commit that referenced this pull request Nov 5, 2018
submodules: update clippy from 71ec4ff to d8b4269

Fixes clippy toolstate.

Changes:

````
rustup #55665 (pass contexts by reference)
Fix typo
Improve clippy_dev help text
RIIR update lints: Generate lint group registrations
Test clippy_dev on CI and fix test
RIIR update lints: Generate modules section
````
flip1995 pushed a commit to flip1995/rust-clippy that referenced this pull request May 5, 2020
Fixes clippy toolstate.

Changes:

````
rustup rust-lang/rust#55665 (pass contexts by reference)
Fix typo
Improve clippy_dev help text
RIIR update lints: Generate lint group registrations
Test clippy_dev on CI and fix test
RIIR update lints: Generate modules section
````
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.

None yet

5 participants