Skip to content

Commit b979e1e

Browse files
authored
Rollup merge of #148994 - folkertdev:abi-compatibility-cleanup, r=jieyouxu
Abi compatibility test cleanup r? `@jieyouxu` - moves `NonNull` (and some friends) into `minicore.rs` so it can be re-used. - tests the abi compatibility of a couple more targets. It's useful to have a comprehensive overview of all ABIs that rust has some amount of support for, e.g. testing for c-variadic or guaranteed tail calls (cc #148748)
2 parents 08093e7 + 96c6427 commit b979e1e

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

tests/auxiliary/minicore.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,24 @@ pub struct ManuallyDrop<T: PointeeSized> {
119119
}
120120
impl<T: Copy + PointeeSized> Copy for ManuallyDrop<T> {}
121121

122+
#[repr(transparent)]
123+
#[rustc_layout_scalar_valid_range_start(1)]
124+
#[rustc_nonnull_optimization_guaranteed]
125+
pub struct NonNull<T: ?Sized> {
126+
pointer: *const T,
127+
}
128+
impl<T: ?Sized> Copy for NonNull<T> {}
129+
130+
#[repr(transparent)]
131+
#[rustc_layout_scalar_valid_range_start(1)]
132+
#[rustc_nonnull_optimization_guaranteed]
133+
pub struct NonZero<T>(T);
134+
135+
pub struct Unique<T: ?Sized> {
136+
pub pointer: NonNull<T>,
137+
pub _marker: PhantomData<T>,
138+
}
139+
122140
#[lang = "unsafe_cell"]
123141
#[repr(transparent)]
124142
pub struct UnsafeCell<T: PointeeSized> {

tests/ui/abi/compatibility.rs

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
//@ revisions: arm
1414
//@[arm] compile-flags: --target arm-unknown-linux-gnueabi
1515
//@[arm] needs-llvm-components: arm
16+
//@ revisions: thumb
17+
//@[thumb] compile-flags: --target thumbv8m.main-none-eabi
18+
//@[thumb] needs-llvm-components: arm
1619
//@ revisions: aarch64
1720
//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu
1821
//@[aarch64] needs-llvm-components: aarch64
@@ -31,12 +34,21 @@
3134
//@ revisions: sparc64
3235
//@[sparc64] compile-flags: --target sparc64-unknown-linux-gnu
3336
//@[sparc64] needs-llvm-components: sparc
37+
//@ revisions: powerpc
38+
//@[powerpc] compile-flags: --target powerpc-unknown-linux-gnu
39+
//@[powerpc] needs-llvm-components: powerpc
3440
//@ revisions: powerpc64
3541
//@[powerpc64] compile-flags: --target powerpc64-unknown-linux-gnu
3642
//@[powerpc64] needs-llvm-components: powerpc
43+
//@ revisions: aix
44+
//@[aix] compile-flags: --target powerpc64-ibm-aix
45+
//@[aix] needs-llvm-components: powerpc
3746
//@ revisions: riscv
3847
//@[riscv] compile-flags: --target riscv64gc-unknown-linux-gnu
3948
//@[riscv] needs-llvm-components: riscv
49+
//@ revisions: loongarch32
50+
//@[loongarch32] compile-flags: --target loongarch32-unknown-none
51+
//@[loongarch32] needs-llvm-components: loongarch
4052
//@ revisions: loongarch64
4153
//@[loongarch64] compile-flags: --target loongarch64-unknown-linux-gnu
4254
//@[loongarch64] needs-llvm-components: loongarch
@@ -87,31 +99,13 @@ mod prelude {
8799
fn clone(&self) -> Self;
88100
}
89101

90-
#[repr(transparent)]
91-
#[rustc_layout_scalar_valid_range_start(1)]
92-
#[rustc_nonnull_optimization_guaranteed]
93-
pub struct NonNull<T: ?Sized> {
94-
pointer: *const T,
95-
}
96-
impl<T: ?Sized> Copy for NonNull<T> {}
97-
98-
#[repr(transparent)]
99-
#[rustc_layout_scalar_valid_range_start(1)]
100-
#[rustc_nonnull_optimization_guaranteed]
101-
pub struct NonZero<T>(T);
102-
103102
// This just stands in for a non-trivial type.
104103
pub struct Vec<T> {
105104
ptr: NonNull<T>,
106105
cap: usize,
107106
len: usize,
108107
}
109108

110-
pub struct Unique<T: ?Sized> {
111-
pub pointer: NonNull<T>,
112-
pub _marker: PhantomData<T>,
113-
}
114-
115109
#[lang = "global_alloc_ty"]
116110
pub struct Global;
117111

tests/ui/cmse-nonsecure/cmse-nonsecure-entry/c-variadic.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,8 @@ async unsafe extern "cmse-nonsecure-entry" fn async_is_not_allowed() {
3131
// this file, but they may be moved into `minicore` if/when other `#[no_core]` tests want to use
3232
// them.
3333

34-
// NOTE: in `core` this type uses `NonNull`.
3534
#[lang = "ResumeTy"]
36-
pub struct ResumeTy(*mut Context<'static>);
35+
pub struct ResumeTy(NonNull<Context<'static>>);
3736

3837
#[lang = "future_trait"]
3938
pub trait Future {

0 commit comments

Comments
 (0)