forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#129487 - GrigorenkoPV:repr_transparent_exte…
…rnal_private_fields, r=compiler-errors repr_transparent_external_private_fields: special-case some std types Fixes rust-lang#129470 ``@rustbot`` label +A-lint +L-repr_transparent_external_private_fields
- Loading branch information
Showing
13 changed files
with
113 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#![feature(rustc_attrs, transparent_unions)] | ||
|
||
#[rustc_pub_transparent] | ||
#[repr(transparent)] | ||
union E<T: Copy> { | ||
value: T, | ||
uninit: (), | ||
} | ||
|
||
#[repr(transparent)] | ||
#[rustc_pub_transparent] | ||
struct S<T>(T); | ||
|
||
#[rustc_pub_transparent] //~ ERROR attribute should be applied to `#[repr(transparent)]` types | ||
#[repr(C)] | ||
struct S1 { | ||
A: u8, | ||
} | ||
|
||
#[rustc_pub_transparent] //~ ERROR attribute should be applied to `#[repr(transparent)]` types | ||
struct S2<T> { | ||
value: T, | ||
} | ||
|
||
fn main() {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
error: attribute should be applied to `#[repr(transparent)]` types | ||
--> $DIR/rustc_pub_transparent.rs:14:1 | ||
| | ||
LL | #[rustc_pub_transparent] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | #[repr(C)] | ||
LL | / struct S1 { | ||
LL | | A: u8, | ||
LL | | } | ||
| |_- not a `#[repr(transparent)]` type | ||
|
||
error: attribute should be applied to `#[repr(transparent)]` types | ||
--> $DIR/rustc_pub_transparent.rs:20:1 | ||
| | ||
LL | #[rustc_pub_transparent] | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^ | ||
LL | / struct S2<T> { | ||
LL | | value: T, | ||
LL | | } | ||
| |_- not a `#[repr(transparent)]` type | ||
|
||
error: aborting due to 2 previous errors | ||
|
25 changes: 25 additions & 0 deletions
25
tests/ui/repr/repr-transparent-non-exhaustive-transparent-in-prose.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
//@ check-pass | ||
|
||
#![feature(sync_unsafe_cell)] | ||
#![allow(unused)] | ||
#![deny(repr_transparent_external_private_fields)] | ||
|
||
// https://github.com/rust-lang/rust/issues/129470 | ||
|
||
struct ZST; | ||
|
||
#[repr(transparent)] | ||
struct TransparentWithManuallyDropZST { | ||
value: i32, | ||
md: std::mem::ManuallyDrop<ZST>, | ||
mu: std::mem::MaybeUninit<ZST>, | ||
p: std::pin::Pin<ZST>, | ||
pd: std::marker::PhantomData<ZST>, | ||
pp: std::marker::PhantomPinned, | ||
c: std::cell::Cell<ZST>, | ||
uc: std::cell::UnsafeCell<ZST>, | ||
suc: std::cell::SyncUnsafeCell<ZST>, | ||
zst: ZST, | ||
} | ||
|
||
fn main() {} |