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#99020 - fee1-dead-contrib:repr_transparent_…
…non_exhaustive, r=oli-obk check non_exhaustive attr and private fields for transparent types Fixes rust-lang#78586.
- Loading branch information
Showing
5 changed files
with
358 additions
and
5 deletions.
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
18 changes: 18 additions & 0 deletions
18
src/test/ui/repr/auxiliary/repr-transparent-non-exhaustive.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,18 @@ | ||
#![crate_type = "lib"] | ||
|
||
pub struct Private { _priv: () } | ||
|
||
#[non_exhaustive] | ||
pub struct NonExhaustive {} | ||
|
||
#[non_exhaustive] | ||
pub enum NonExhaustiveEnum {} | ||
|
||
pub enum NonExhaustiveVariant { | ||
#[non_exhaustive] | ||
A, | ||
} | ||
|
||
pub struct ExternalIndirection<T> { | ||
pub x: T, | ||
} |
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,96 @@ | ||
#![deny(repr_transparent_external_private_fields)] | ||
|
||
// aux-build: repr-transparent-non-exhaustive.rs | ||
extern crate repr_transparent_non_exhaustive; | ||
|
||
use repr_transparent_non_exhaustive::{ | ||
Private, | ||
NonExhaustive, | ||
NonExhaustiveEnum, | ||
NonExhaustiveVariant, | ||
ExternalIndirection, | ||
}; | ||
|
||
pub struct InternalPrivate { | ||
_priv: (), | ||
} | ||
|
||
#[non_exhaustive] | ||
pub struct InternalNonExhaustive; | ||
|
||
pub struct InternalIndirection<T> { | ||
x: T, | ||
} | ||
|
||
pub type Sized = i32; | ||
|
||
#[repr(transparent)] | ||
pub struct T1(Sized, InternalPrivate); | ||
#[repr(transparent)] | ||
pub struct T2(Sized, InternalNonExhaustive); | ||
#[repr(transparent)] | ||
pub struct T3(Sized, InternalIndirection<(InternalPrivate, InternalNonExhaustive)>); | ||
#[repr(transparent)] | ||
pub struct T4(Sized, ExternalIndirection<(InternalPrivate, InternalNonExhaustive)>); | ||
|
||
#[repr(transparent)] | ||
pub struct T5(Sized, Private); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T6(Sized, NonExhaustive); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T7(Sized, NonExhaustiveEnum); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T8(Sized, NonExhaustiveVariant); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T9(Sized, InternalIndirection<Private>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T10(Sized, InternalIndirection<NonExhaustive>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T11(Sized, InternalIndirection<NonExhaustiveEnum>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T12(Sized, InternalIndirection<NonExhaustiveVariant>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T13(Sized, ExternalIndirection<Private>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T14(Sized, ExternalIndirection<NonExhaustive>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T15(Sized, ExternalIndirection<NonExhaustiveEnum>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
#[repr(transparent)] | ||
pub struct T16(Sized, ExternalIndirection<NonExhaustiveVariant>); | ||
//~^ ERROR zero-sized fields in repr(transparent) cannot contain external non-exhaustive types | ||
//~| WARN this was previously accepted by the compiler | ||
|
||
fn main() {} |
Oops, something went wrong.