-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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 #115708 - RalfJung:homogeneous, r=davidtwco
fix homogeneous_aggregate not ignoring some ZST This is an ABI-breaking change, because it fixes bugs in our ABI code. I'm not sure what that means for this PR, we don't really have a process for such changes, do we? I can only hope nobody relied on the old buggy behavior. Fixes #115664
- Loading branch information
Showing
4 changed files
with
87 additions
and
12 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
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,44 @@ | ||
#![feature(rustc_attrs)] | ||
#![feature(transparent_unions)] | ||
use std::marker::PhantomData; | ||
|
||
// Regression test for #115664. We want to ensure that `repr(transparent)` wrappers do not affect | ||
// the result of `homogeneous_aggregate`. | ||
|
||
type Tuple = (f32, f32, f32); | ||
|
||
struct Zst; | ||
|
||
#[repr(transparent)] | ||
struct Wrapper1<T>(T); | ||
#[repr(transparent)] | ||
struct Wrapper2<T>((), Zst, T); | ||
#[repr(transparent)] | ||
struct Wrapper3<T>(T, [u8; 0], PhantomData<u64>); | ||
#[repr(transparent)] | ||
union WrapperUnion<T: Copy> { | ||
nothing: (), | ||
something: T, | ||
} | ||
|
||
#[rustc_layout(homogeneous_aggregate)] | ||
pub type Test0 = Tuple; | ||
//~^ ERROR homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
|
||
#[rustc_layout(homogeneous_aggregate)] | ||
pub type Test1 = Wrapper1<Tuple>; | ||
//~^ ERROR homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
|
||
#[rustc_layout(homogeneous_aggregate)] | ||
pub type Test2 = Wrapper2<Tuple>; | ||
//~^ ERROR homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
|
||
#[rustc_layout(homogeneous_aggregate)] | ||
pub type Test3 = Wrapper3<Tuple>; | ||
//~^ ERROR homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
|
||
#[rustc_layout(homogeneous_aggregate)] | ||
pub type Test4 = WrapperUnion<Tuple>; | ||
//~^ ERROR homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
|
||
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,32 @@ | ||
error: homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
--> $DIR/homogeneous-aggr-transparent.rs:25:1 | ||
| | ||
LL | pub type Test0 = Tuple; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
--> $DIR/homogeneous-aggr-transparent.rs:29:1 | ||
| | ||
LL | pub type Test1 = Wrapper1<Tuple>; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
--> $DIR/homogeneous-aggr-transparent.rs:33:1 | ||
| | ||
LL | pub type Test2 = Wrapper2<Tuple>; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
--> $DIR/homogeneous-aggr-transparent.rs:37:1 | ||
| | ||
LL | pub type Test3 = Wrapper3<Tuple>; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: homogeneous_aggregate: Ok(Homogeneous(Reg { kind: Float, size: Size(4 bytes) })) | ||
--> $DIR/homogeneous-aggr-transparent.rs:41:1 | ||
| | ||
LL | pub type Test4 = WrapperUnion<Tuple>; | ||
| ^^^^^^^^^^^^^^ | ||
|
||
error: aborting due to 5 previous errors | ||
|