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

offset_of: don't require type to be Sized #112069

Merged
merged 1 commit into from
May 31, 2023

Conversation

clubby789
Copy link
Contributor

@clubby789 clubby789 commented May 29, 2023

Fixes #112051

The RFC explicitly forbids non-Sized types, but it looks like only the fields being recursed into were checked. The sized check also seemed to have been completely missing for tuples

@clubby789 clubby789 added the F-offset_of `#![feature(offset_of)]` label May 29, 2023
@rustbot
Copy link
Collaborator

rustbot commented May 29, 2023

r? @cjgillot

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 29, 2023
@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@WaffleLapkin WaffleLapkin left a comment

Choose a reason for hiding this comment

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

r=me with the nit below

tests/ui/offset-of/offset-of-unsized-disallowed.rs Outdated Show resolved Hide resolved
@WaffleLapkin
Copy link
Member

r? @WaffleLapkin

@rustbot rustbot assigned WaffleLapkin and unassigned cjgillot May 29, 2023
@rust-log-analyzer

This comment has been minimized.

@clubby789
Copy link
Contributor Author

Hmm, it looks like these tests are testing things that the RFC currently disallows 🤔
@drmeepster any thoughts?

@beepster4096
Copy link
Contributor

The RFC is intentionally limited to allow a pure library implementation. My implementation also included several of the future possibilities, including supporting DSTs.

@Noratrieb
Copy link
Member

I don't think there are any implementation concerns with allowing unsized fields, so there's no reason not to.

@est31
Copy link
Member

est31 commented May 29, 2023

Yeah the ability to get the offset of fields that are part of the sized prelude of an unsized type would be great. This is one of the things that is impossible to do (in a sound way) in libraries but it is needed by the users of one of the projects I maintain.

@clubby789 clubby789 changed the title offset_of: check all fields are Sized offset_of: don't require type to be Sized May 29, 2023
@WaffleLapkin
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented May 30, 2023

📌 Commit 6c18d1e has been approved by WaffleLapkin

It is now in the queue for this repository.

@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 May 30, 2023
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request May 30, 2023
…r=WaffleLapkin

offset_of: don't require type to be `Sized`

Fixes rust-lang#112051

~~The RFC [explicitly forbids](https://rust-lang.github.io/rfcs/3308-offset_of.html#limitations) non-`Sized` types, but it looks like only the fields being recursed into were checked. The sized check also seemed to have been completely missing for tuples~~
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2023
…iaskrgr

Rollup of 7 pull requests

Successful merges:

 - rust-lang#112031 (Migrate  `item_proc_macro` to Askama)
 - rust-lang#112053 (Remove `-Zcgu-partitioning-strategy`.)
 - rust-lang#112069 (offset_of: don't require type to be `Sized`)
 - rust-lang#112084 (enhancements on  build_helper utilization and rustdoc-gui-test)
 - rust-lang#112096 (Remove array_zip)
 - rust-lang#112108 (Fix re-export of doc hidden item inside private item not displayed)
 - rust-lang#112113 (rustdoc: simplify `clean` by removing `FnRetTy`)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit f589451 into rust-lang:master May 31, 2023
@rustbot rustbot added this to the 1.72.0 milestone May 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-offset_of `#![feature(offset_of)]` S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ICE when using offset_of with an unsized type
9 participants