diff --git a/tests/ui/abi/compatibility.rs b/tests/ui/abi/compatibility.rs index b439a4bcf867b..ef2719287c40f 100644 --- a/tests/ui/abi/compatibility.rs +++ b/tests/ui/abi/compatibility.rs @@ -58,135 +58,23 @@ //@ revisions: nvptx64 //@[nvptx64] compile-flags: --target nvptx64-nvidia-cuda //@[nvptx64] needs-llvm-components: nvptx -#![feature(rustc_attrs, unsized_fn_params, transparent_unions)] -#![cfg_attr(not(host), feature(no_core, lang_items), no_std, no_core)] -#![allow(unused, improper_ctypes_definitions, internal_features)] // FIXME: some targets are broken in various ways. // Hence there are `cfg` throughout this test to disable parts of it on those targets. // sparc64: https://github.com/rust-lang/rust/issues/115336 // mips64: https://github.com/rust-lang/rust/issues/115404 -#[cfg(host)] -use std::{ - any::Any, marker::PhantomData, mem::ManuallyDrop, num::NonZero, ptr::NonNull, rc::Rc, sync::Arc, -}; - -/// To work cross-target this test must be no_core. -/// This little prelude supplies what we need. -#[cfg(not(host))] -mod prelude { - #[lang = "sized"] - pub trait Sized {} - - #[lang = "receiver"] - pub trait Receiver {} - impl Receiver for &T {} - impl Receiver for &mut T {} - - #[lang = "copy"] - pub trait Copy: Sized {} - impl Copy for i32 {} - impl Copy for f32 {} - impl Copy for &T {} - impl Copy for *const T {} - impl Copy for *mut T {} - - #[lang = "clone"] - pub trait Clone: Sized { - fn clone(&self) -> Self; - } - - #[lang = "phantom_data"] - pub struct PhantomData; - impl Copy for PhantomData {} - - #[lang = "unsafe_cell"] - #[repr(transparent)] - pub struct UnsafeCell { - value: T, - } - - pub trait Any: 'static {} - - pub enum Option { - None, - Some(T), - } - impl Copy for Option {} - - pub enum Result { - Ok(T), - Err(E), - } - impl Copy for Result {} - - #[lang = "manually_drop"] - #[repr(transparent)] - pub struct ManuallyDrop { - value: T, - } - impl Copy for ManuallyDrop {} +#![feature(no_core)] +#![no_core] +#![no_std] - #[repr(transparent)] - #[rustc_layout_scalar_valid_range_start(1)] - #[rustc_nonnull_optimization_guaranteed] - pub struct NonNull { - pointer: *const T, - } - impl Copy for NonNull {} - - #[repr(transparent)] - #[rustc_layout_scalar_valid_range_start(1)] - #[rustc_nonnull_optimization_guaranteed] - pub struct NonZero(T); - - // This just stands in for a non-trivial type. - pub struct Vec { - ptr: NonNull, - cap: usize, - len: usize, - } - - pub struct Unique { - pub pointer: NonNull, - pub _marker: PhantomData, - } - - #[lang = "global_alloc_ty"] - pub struct Global; - - #[lang = "owned_box"] - pub struct Box(Unique, A); - - #[repr(C)] - struct RcBox { - strong: UnsafeCell, - weak: UnsafeCell, - value: T, - } - pub struct Rc { - ptr: NonNull>, - phantom: PhantomData>, - alloc: A, - } +#![feature(unsized_fn_params, transparent_unions, rustc_attrs)] +#![allow(unused, improper_ctypes_definitions, internal_features)] - #[repr(C, align(8))] - struct AtomicUsize(usize); - #[repr(C)] - struct ArcInner { - strong: AtomicUsize, - weak: AtomicUsize, - data: T, - } - pub struct Arc { - ptr: NonNull>, - phantom: PhantomData>, - alloc: A, - } -} -#[cfg(not(host))] -use prelude::*; +//@ use-minicore +extern crate minicore; +use minicore as _; +use minicore::*; macro_rules! test_abi_compatible { ($name:ident, $t1:ty, $t2:ty) => {