Skip to content

Commit 82d17a4

Browse files
committed
Auto merge of #130500 - matthiaskrgr:rollup-lfx3bb4, r=matthiaskrgr
Rollup of 3 pull requests Successful merges: - #130466 (tests: add repr/transparent test for aarch64) - #130468 (Make sure that def id <=> lang item map is bidirectional) - #130499 (Add myself to the libs review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f68c28b + d20649e commit 82d17a4

File tree

5 files changed

+127
-4
lines changed

5 files changed

+127
-4
lines changed

compiler/rustc_hir/src/lang_items.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ impl LanguageItems {
4545

4646
pub fn set(&mut self, item: LangItem, def_id: DefId) {
4747
self.items[item as usize] = Some(def_id);
48-
self.reverse_items.insert(def_id, item);
48+
let preexisting = self.reverse_items.insert(def_id, item);
49+
50+
// This needs to be a bijection.
51+
if let Some(preexisting) = preexisting {
52+
panic!(
53+
"For the bijection of LangItem <=> DefId to work,\
54+
one item DefId may only be assigned one LangItem. \
55+
Separate the LangItem definitions for {item:?} and {preexisting:?}."
56+
);
57+
}
4958
}
5059

5160
pub fn from_def_id(&self, def_id: DefId) -> Option<LangItem> {

tests/codegen/repr/transparent-struct-ptr.rs tests/codegen/repr/transparent-byval-struct-ptr.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414

1515
// See ./transparent.rs
1616
// Some platforms pass large aggregates using immediate arrays in LLVMIR
17-
// Other platforms pass large aggregates using struct pointer in LLVMIR
18-
// This covers the "struct pointer" case.
17+
// Other platforms pass large aggregates using by-value struct pointer in LLVMIR
18+
// Yet more platforms pass large aggregates using opaque pointer in LLVMIR
19+
// This covers the "by-value struct pointer" case.
1920

2021
#![feature(no_core, lang_items, transparent_unions)]
2122
#![crate_type = "lib"]

tests/codegen/repr/transparent-imm-array.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818

1919
// See ./transparent.rs
2020
// Some platforms pass large aggregates using immediate arrays in LLVMIR
21-
// Other platforms pass large aggregates using struct pointer in LLVMIR
21+
// Other platforms pass large aggregates using by-value struct pointer in LLVMIR
22+
// Yet more platforms pass large aggregates using opaque pointer in LLVMIR
2223
// This covers the "immediate array" case.
2324

2425
#![feature(no_core, lang_items, transparent_unions)]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
//@ revisions: aarch64-linux aarch64-darwin
2+
//@ compile-flags: -O -C no-prepopulate-passes
3+
4+
//@[aarch64-linux] compile-flags: --target aarch64-unknown-linux-gnu
5+
//@[aarch64-linux] needs-llvm-components: aarch64
6+
//@[aarch64-darwin] compile-flags: --target aarch64-apple-darwin
7+
//@[aarch64-darwin] needs-llvm-components: aarch64
8+
9+
// See ./transparent.rs
10+
// Some platforms pass large aggregates using immediate arrays in LLVMIR
11+
// Other platforms pass large aggregates using by-value struct pointer in LLVMIR
12+
// Yet more platforms pass large aggregates using opaque pointer in LLVMIR
13+
// This covers the "opaque pointer" case.
14+
15+
#![feature(no_core, lang_items, transparent_unions)]
16+
#![crate_type = "lib"]
17+
#![no_std]
18+
#![no_core]
19+
20+
#[lang = "sized"]
21+
trait Sized {}
22+
#[lang = "freeze"]
23+
trait Freeze {}
24+
#[lang = "copy"]
25+
trait Copy {}
26+
27+
impl Copy for [u32; 16] {}
28+
impl Copy for BigS {}
29+
impl Copy for BigU {}
30+
31+
#[repr(C)]
32+
pub struct BigS([u32; 16]);
33+
34+
#[repr(transparent)]
35+
pub struct TsBigS(BigS);
36+
37+
#[repr(transparent)]
38+
pub union TuBigS {
39+
field: BigS,
40+
}
41+
42+
#[repr(transparent)]
43+
pub enum TeBigS {
44+
Variant(BigS),
45+
}
46+
47+
// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], ptr [[BIGS_ARG_ATTRS1:.*]])
48+
#[no_mangle]
49+
pub extern "C" fn test_BigS(_: BigS) -> BigS {
50+
loop {}
51+
}
52+
53+
// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]])
54+
#[no_mangle]
55+
pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS {
56+
loop {}
57+
}
58+
59+
// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]])
60+
#[no_mangle]
61+
pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS {
62+
loop {}
63+
}
64+
65+
// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]])
66+
#[no_mangle]
67+
pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS {
68+
loop {}
69+
}
70+
71+
#[repr(C)]
72+
pub union BigU {
73+
foo: [u32; 16],
74+
}
75+
76+
#[repr(transparent)]
77+
pub struct TsBigU(BigU);
78+
79+
#[repr(transparent)]
80+
pub union TuBigU {
81+
field: BigU,
82+
}
83+
84+
#[repr(transparent)]
85+
pub enum TeBigU {
86+
Variant(BigU),
87+
}
88+
89+
// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1:.*]])
90+
#[no_mangle]
91+
pub extern "C" fn test_BigU(_: BigU) -> BigU {
92+
loop {}
93+
}
94+
95+
// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]])
96+
#[no_mangle]
97+
pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU {
98+
loop {}
99+
}
100+
101+
// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]])
102+
#[no_mangle]
103+
pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU {
104+
loop {}
105+
}
106+
107+
// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]])
108+
#[no_mangle]
109+
pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU {
110+
loop {}
111+
}

triagebot.toml

+1
Original file line numberDiff line numberDiff line change
@@ -966,6 +966,7 @@ libs = [
966966
"@jhpratt",
967967
"@tgross35",
968968
"@thomcc",
969+
"@ibraheemdev",
969970
]
970971
bootstrap = [
971972
"@Mark-Simulacrum",

0 commit comments

Comments
 (0)