]> git.lizzy.rs Git - rust.git/blob - tests/codegen/tuple-layout-opt.rs
Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r...
[rust.git] / tests / codegen / tuple-layout-opt.rs
1 // ignore-emscripten
2 // compile-flags: -C no-prepopulate-passes -Copt-level=0
3
4 // Test that tuples get optimized layout, in particular with a ZST in the last field (#63244)
5
6 #![crate_type="lib"]
7
8 type ScalarZstLast = (u128, ());
9 // CHECK: define i128 @test_ScalarZstLast(i128 %_1)
10 #[no_mangle]
11 pub fn test_ScalarZstLast(_: ScalarZstLast) -> ScalarZstLast { loop {} }
12
13 type ScalarZstFirst = ((), u128);
14 // CHECK: define i128 @test_ScalarZstFirst(i128 %_1)
15 #[no_mangle]
16 pub fn test_ScalarZstFirst(_: ScalarZstFirst) -> ScalarZstFirst { loop {} }
17
18 type ScalarPairZstLast = (u8, u128, ());
19 // CHECK: define { i128, i8 } @test_ScalarPairZstLast(i128 %_1.0, i8 %_1.1)
20 #[no_mangle]
21 pub fn test_ScalarPairZstLast(_: ScalarPairZstLast) -> ScalarPairZstLast { loop {} }
22
23 type ScalarPairZstFirst = ((), u8, u128);
24 // CHECK: define { i8, i128 } @test_ScalarPairZstFirst(i8 %_1.0, i128 %_1.1)
25 #[no_mangle]
26 pub fn test_ScalarPairZstFirst(_: ScalarPairZstFirst) -> ScalarPairZstFirst { loop {} }
27
28 type ScalarPairLotsOfZsts = ((), u8, (), u128, ());
29 // CHECK: define { i128, i8 } @test_ScalarPairLotsOfZsts(i128 %_1.0, i8 %_1.1)
30 #[no_mangle]
31 pub fn test_ScalarPairLotsOfZsts(_: ScalarPairLotsOfZsts) -> ScalarPairLotsOfZsts { loop {} }
32
33 type ScalarPairLottaNesting = (((), ((), u8, (), u128, ())), ());
34 // CHECK: define { i128, i8 } @test_ScalarPairLottaNesting(i128 %_1.0, i8 %_1.1)
35 #[no_mangle]
36 pub fn test_ScalarPairLottaNesting(_: ScalarPairLottaNesting) -> ScalarPairLottaNesting { loop {} }