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

Make ThinBox<T> covariant in T #98585

Merged
merged 1 commit into from
Jul 1, 2022
Merged

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Jun 27, 2022

Just like Box<T>, we want ThinBox<T> to be covariant in T, but the
projection in WithHeader<<T as Pointee>::Metadata> was making it
invariant. This is now hidden as WithOpaqueHeader, which we type-cast
whenever the real WithHeader<H> type is needed.

Fixes the problem noted in #92791 (comment).

Just like `Box<T>`, we want `ThinBox<T>` to be covariant in `T`, but the
projection in `WithHeader<<T as Pointee>::Metadata>` was making it
invariant. This is now hidden as `WithOpaqueHeader`, which we type-cast
whenever the real `WithHeader<H>` type is needed.
@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jun 27, 2022
@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive
Copy link
Collaborator

r? @thomcc

(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 Jun 27, 2022
Copy link
Member

@thomcc thomcc left a comment

Choose a reason for hiding this comment

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

Very clever. IMO ideally there would be really nice if there were a way to do this with more "naive" use of Pointee, but this is a nice solution

@thomcc
Copy link
Member

thomcc commented Jun 27, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jun 27, 2022

📌 Commit e67e165 has been approved by thomcc

@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 Jun 27, 2022
@thomcc
Copy link
Member

thomcc commented Jun 27, 2022

Ah crap, should this have gone through t-libs-api? Since it's a change to an unstable API?

@thomcc
Copy link
Member

thomcc commented Jun 27, 2022

Impl looks great, but as this is an API change to ThinBox, I probably shouldn't just r+ it.

@bors r-

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label Jun 27, 2022
@bors bors removed the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jun 27, 2022
@rustbot rustbot removed the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jun 27, 2022
@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jun 27, 2022
@cuviper
Copy link
Member Author

cuviper commented Jun 27, 2022

@rustbot label -S-waiting-on-author +S-waiting-on-review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 27, 2022
@cuviper cuviper mentioned this pull request Jun 28, 2022
4 tasks
@thomcc
Copy link
Member

thomcc commented Jun 30, 2022

So wait, what was the outcome of the meeting today? Is it okay to r+ this?

I mean, it's desirable (IMO), and people have had time to weigh in (probably).

@cuviper
Copy link
Member Author

cuviper commented Jun 30, 2022

Yeah, I think it's fine, especially since the tracking issue was asking "can we", not "should we", and it's still unstable.

@thomcc
Copy link
Member

thomcc commented Jun 30, 2022

Alright!

@bors r+

@bors
Copy link
Contributor

bors commented Jun 30, 2022

📌 Commit e67e165 has been approved by thomcc

@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 Jun 30, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 1, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#97488 (Suggest blanket impl to the local traits)
 - rust-lang#98585 (Make `ThinBox<T>` covariant in `T`)
 - rust-lang#98644 (fix ICE with -Wrust-2021-incompatible-closure-captures)
 - rust-lang#98739 (fix grammar in useless doc comment lint)
 - rust-lang#98741 (Many small deriving cleanups)
 - rust-lang#98756 (Use const instead of function and make it private)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 9dd3288 into rust-lang:master Jul 1, 2022
@cuviper cuviper deleted the covariant-thinbox branch October 15, 2022 00:16
@cuviper cuviper added this to the 1.64.0 milestone Nov 16, 2023
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. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants