Closed
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)