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

repr(transparent): it's fine if the one non-1-ZST field is a ZST #115334

Merged
merged 2 commits into from
Sep 17, 2023

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented Aug 29, 2023

This code currently gets rejected:

#[repr(transparent)]
struct MyType([u16; 0])

That clearly seems like a bug to me: repr(transparent) got defined as having any number of 1-ZST fields plus optionally one more field; MyType clearly satisfies that definition.

This PR changes the repr(transparent) logic to actually match that definition.

@rustbot
Copy link
Collaborator

rustbot commented Aug 29, 2023

r? @TaKO8Ki

(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 Aug 29, 2023
@RalfJung
Copy link
Member Author

Nominating for T-lang since this is a change in public behavior on stable -- but we already had an FCP blessing this so I don't think we need a full FCP again.

@RalfJung RalfJung added T-lang Relevant to the language team, which will review and decide on the PR/issue. I-lang-nominated Nominated for discussion during a lang team meeting. and removed T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 29, 2023
@fmease
Copy link
Member

fmease commented Aug 29, 2023

That's great, when working on a fix for #90435 (which is now sadly blocked on #114952 I guess), I've noticed that

#[repr(transparent)] struct S(_1Zst, Zst);
struct _1Zst;
#[repr(align(2))] struct Zst;

currently doesn't compile. This should be fixed by this PR, right?

@RalfJung
Copy link
Member Author

Yes that should be fixed by this PR.

@scottmcm
Copy link
Member

I agree that this doesn't need another lang sign-off since it's what was explicitly FCP'd before. (Sadly we didn't get to it in the meeting today, so I'm only speaking for me.)

@scottmcm
Copy link
Member

Since this is opening up something new, could we fix #90435 & #90435 for this case as part of this change?

(Fixing those issues for existing code is harder, but if they didn't compile before maybe we can do it here?)

@fmease
Copy link
Member

fmease commented Sep 1, 2023

I've opened #115439 to fix #90435.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 1, 2023

Since this is opening up something new, could we fix #90435 & #90435 for this case as part of this change?

I'm not sure if this has to be entangled with rustdoc changes. That's an entirely orthogonal discussion IMO.

@joshtriplett joshtriplett removed the I-lang-nominated Nominated for discussion during a lang team meeting. label Sep 5, 2023
@scottmcm
Copy link
Member

scottmcm commented Sep 5, 2023

We discussed this briefly in the lang triage meeting today, and the meeting was in agreement that the previous FCP applies, and that we're happy to see this addressed.

@RalfJung
Copy link
Member Author

RalfJung commented Sep 5, 2023

@TaKO8Ki the ball is in your court then. :)

@RalfJung
Copy link
Member Author

This has lang team approval so for the review I suppose it's a t-compiler job.
r? compiler

@rustbot rustbot assigned compiler-errors and unassigned TaKO8Ki Sep 12, 2023
@RalfJung RalfJung added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 12, 2023
@compiler-errors
Copy link
Member

LGTM

@bors r+

@bors
Copy link
Contributor

bors commented Sep 16, 2023

📌 Commit a6ccd26 has been approved by compiler-errors

It is now in the queue for this repository.

@bors bors removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 16, 2023
@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Sep 16, 2023
@bors
Copy link
Contributor

bors commented Sep 17, 2023

⌛ Testing commit a6ccd26 with merge 203c57d...

@bors
Copy link
Contributor

bors commented Sep 17, 2023

☀️ Test successful - checks-actions
Approved by: compiler-errors
Pushing 203c57d to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 17, 2023
@bors bors merged commit 203c57d into rust-lang:master Sep 17, 2023
11 checks passed
@rustbot rustbot added this to the 1.74.0 milestone Sep 17, 2023
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (203c57d): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.4% [-2.4%, -2.4%] 1
Improvements ✅
(secondary)
-3.1% [-3.4%, -2.9%] 2
All ❌✅ (primary) -2.4% [-2.4%, -2.4%] 1

Cycles

This benchmark run did not return any relevant results for this metric.

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 635.505s -> 634.064s (-0.23%)
Artifact size: 318.39 MiB -> 318.47 MiB (0.02%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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. T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants