- 
                Notifications
    You must be signed in to change notification settings 
- Fork 13.9k
Closed
Labels
C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.
Description
Lifted from #78586
I believe this future compatibility warning was badly affected by #115334. Minimal repro:
// src/lib.rs
#[non_exhaustive]
pub struct ZeroSizedNonExhaustive {}// src/main.rs
#![deny(warnings)]
#[repr(transparent)]
pub struct Transparent(repro::ZeroSizedNonExhaustive);
fn main() {}As far as I understand what this issue is about, this code should be 100% fine. This issue is about preventing a previously-accepted repr(transparent) struct from ending up with contents which a transparent struct is not allowed to have, after a permissible size increase of a non-exhaustive formerly-ZST from a different crate.
That's not possible in the code above. Transparent continues to be a valid repr(transparent) struct if ZeroSizedNonExhaustive increases in size.
Regression in nightly-2023-09-18:
error: zero-sized fields in `repr(transparent)` cannot contain external non-exhaustive types
 --> src/main.rs:6:24
  |
6 | pub struct Transparent(repro::ZeroSizedNonExhaustive);
  |                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
  = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
  = note: for more information, see issue #78586 <https://github.com/rust-lang/rust/issues/78586>
  = note: this struct contains `ZeroSizedNonExhaustive`, which is marked with `#[non_exhaustive]`, and makes it not a breaking change to become non-zero-sized in the future.Originally posted by @dtolnay in #78586 (comment)
Metadata
Metadata
Assignees
Labels
C-bugCategory: This is a bug.Category: This is a bug.P-highHigh priorityHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-nightlyPerformance or correctness regression from stable to nightly.Performance or correctness regression from stable to nightly.