Migrate all tests to the 2024 edition

This commit is contained in:
bjorn3 2025-01-07 15:19:57 +00:00
parent 5782b21cef
commit d24852f515
5 changed files with 76 additions and 70 deletions

View file

@ -20,13 +20,13 @@
"crates": [
{
"root_module": "./example/mini_core.rs",
"edition": "2015",
"edition": "2024",
"deps": [],
"cfg": [],
},
{
"root_module": "./example/mini_core_hello_world.rs",
"edition": "2015",
"edition": "2024",
"deps": [
{
"crate": 0,
@ -37,7 +37,7 @@
},
{
"root_module": "./example/std_example.rs",
"edition": "2015",
"edition": "2024",
"deps": [],
"cfg": [],
},

View file

@ -89,15 +89,7 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
TestCase::custom("aot.gen_block_iterate", &|runner| {
runner.run_rustc([
"example/gen_block_iterate.rs",
"--edition",
"2024",
"-Zunstable-options",
]);
runner.run_out_command("gen_block_iterate", &[]);
}),
TestCase::build_bin_and_run("aot.gen_block_iterate", "example/gen_block_iterate.rs", &[]),
TestCase::build_bin_and_run("aot.raw-dylib", "example/raw-dylib.rs", &[]),
TestCase::custom("test.sysroot", &|runner| {
apply_patches(
@ -423,6 +415,7 @@ impl<'a> TestRunner<'a> {
cmd.arg("-Cpanic=abort");
}
cmd.arg("--check-cfg=cfg(jit)");
cmd.arg("--edition=2024");
cmd.args(args);
cmd
}

View file

@ -81,12 +81,16 @@ pub fn use_size_of() -> usize {
}
pub unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) {
intrinsics::copy::<u8>(src, dst, 1);
unsafe {
intrinsics::copy::<u8>(src, dst, 1);
}
}
pub unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) {
let copy2 = &intrinsics::copy::<u8>;
copy2(src, dst, 1);
unsafe {
let copy2 = &intrinsics::copy::<u8>;
copy2(src, dst, 1);
}
}
pub const ABC: u8 = 6 * 7;
@ -130,11 +134,11 @@ pub fn eq_char(a: char, b: char) -> bool {
}
pub unsafe fn transmute(c: char) -> u32 {
intrinsics::transmute(c)
unsafe { intrinsics::transmute(c) }
}
pub unsafe fn deref_str_ptr(s: *const str) -> &'static str {
&*s
unsafe { &*s }
}
pub fn use_array(arr: [u8; 3]) -> u8 {
@ -150,7 +154,7 @@ pub fn array_as_slice(arr: &[u8; 3]) -> &[u8] {
}
pub unsafe fn use_ctlz_nonzero(a: u16) -> u32 {
intrinsics::ctlz_nonzero(a)
unsafe { intrinsics::ctlz_nonzero(a) }
}
pub fn ptr_as_usize(ptr: *const u8) -> usize {

View file

@ -545,7 +545,7 @@ fn panic_in_cleanup() -> ! {
#[cfg(all(unix, not(target_vendor = "apple")))]
#[link(name = "gcc_s")]
extern "C" {
unsafe extern "C" {
fn _Unwind_Resume(exc: *mut ()) -> !;
}
@ -554,7 +554,9 @@ extern "C" {
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
// Code here does not matter - this is replaced by the
// real drop glue by the compiler.
drop_in_place(to_drop);
unsafe {
drop_in_place(to_drop);
}
}
#[lang = "unpin"]
@ -621,7 +623,7 @@ impl<T: ?Sized> Deref for Box<T> {
#[lang = "exchange_malloc"]
unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
libc::malloc(size)
unsafe { libc::malloc(size) }
}
#[lang = "drop"]
@ -648,11 +650,11 @@ pub mod intrinsics {
#[rustc_intrinsic]
pub fn size_of<T>() -> usize;
#[rustc_intrinsic]
pub unsafe fn size_of_val<T: ?::Sized>(val: *const T) -> usize;
pub unsafe fn size_of_val<T: ?crate::Sized>(val: *const T) -> usize;
#[rustc_intrinsic]
pub fn align_of<T>() -> usize;
#[rustc_intrinsic]
pub unsafe fn align_of_val<T: ?::Sized>(val: *const T) -> usize;
pub unsafe fn align_of_val<T: ?crate::Sized>(val: *const T) -> usize;
#[rustc_intrinsic]
pub unsafe fn copy<T>(src: *const T, dst: *mut T, count: usize);
#[rustc_intrinsic]
@ -660,7 +662,7 @@ pub mod intrinsics {
#[rustc_intrinsic]
pub unsafe fn ctlz_nonzero<T>(x: T) -> u32;
#[rustc_intrinsic]
pub const fn needs_drop<T: ?::Sized>() -> bool;
pub const fn needs_drop<T: ?crate::Sized>() -> bool;
#[rustc_intrinsic]
pub fn bitreverse<T>(x: T) -> T;
#[rustc_intrinsic]
@ -677,13 +679,13 @@ pub mod libc {
// symbols to link against.
#[cfg_attr(unix, link(name = "c"))]
#[cfg_attr(target_env = "msvc", link(name = "legacy_stdio_definitions"))]
extern "C" {
unsafe extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
}
#[cfg_attr(unix, link(name = "c"))]
#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
extern "C" {
unsafe extern "C" {
pub fn puts(s: *const i8) -> i32;
pub fn malloc(size: usize) -> *mut u8;
pub fn free(ptr: *mut u8);
@ -715,7 +717,7 @@ impl<T> Index<usize> for [T] {
}
}
extern "C" {
unsafe extern "C" {
type VaListImpl;
}
@ -774,7 +776,7 @@ struct PanicLocation {
column: u32,
}
#[no_mangle]
#[unsafe(no_mangle)]
#[cfg(not(all(windows, target_env = "gnu")))]
pub fn get_tls() -> u8 {
#[thread_local]

View file

@ -115,9 +115,11 @@ static mut NUM: u8 = 6 * 7;
static NUM_REF: &'static u8 = unsafe { &*&raw const NUM };
unsafe fn zeroed<T>() -> T {
let mut uninit = MaybeUninit { uninit: () };
intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0, 1);
uninit.value.value
unsafe {
let mut uninit = MaybeUninit { uninit: () };
intrinsics::write_bytes(&mut uninit.value.value as *mut T, 0, 1);
uninit.value.value
}
}
fn take_f32(_f: f32) {}
@ -228,7 +230,7 @@ fn main() {
}
unsafe fn uninitialized<T>() -> T {
MaybeUninit { uninit: () }.value.value
unsafe { MaybeUninit { uninit: () }.value.value }
}
zeroed::<(u8, u8)>();
@ -261,20 +263,20 @@ fn main() {
let x = &[0u32, 42u32] as &[u32];
match x {
[] => assert_eq!(0u32, 1),
[_, ref y @ ..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize),
[_, y @ ..] => assert_eq!(&x[1] as *const u32 as usize, &y[0] as *const u32 as usize),
}
assert_eq!(((|()| 42u8) as fn(()) -> u8)(()), 42);
#[cfg(not(any(jit, target_vendor = "apple", windows)))]
{
extern "C" {
unsafe extern "C" {
#[linkage = "extern_weak"]
static ABC: *const u8;
}
{
extern "C" {
unsafe extern "C" {
#[linkage = "extern_weak"]
static ABC: *const u8;
}
@ -301,7 +303,7 @@ fn main() {
check_niche_behavior();
extern "C" {
unsafe extern "C" {
type ExternType;
}
@ -354,7 +356,7 @@ fn stack_val_align() {
}
#[cfg(all(not(jit), target_arch = "x86_64", any(target_os = "linux", target_os = "macos")))]
extern "C" {
unsafe extern "C" {
fn global_asm_test();
}
@ -402,7 +404,7 @@ struct pthread_attr_t {
#[link(name = "pthread")]
#[cfg(unix)]
extern "C" {
unsafe extern "C" {
fn pthread_attr_init(attr: *mut pthread_attr_t) -> c_int;
fn pthread_create(
@ -423,7 +425,7 @@ type HANDLE = *mut c_void;
#[link(name = "msvcrt")]
#[cfg(windows)]
extern "C" {
unsafe extern "C" {
fn WaitForSingleObject(hHandle: LPVOID, dwMilliseconds: DWORD) -> DWORD;
fn CreateThread(
@ -445,46 +447,51 @@ struct Thread {
impl Thread {
unsafe fn create(f: extern "C" fn(_: *mut c_void) -> *mut c_void) -> Self {
#[cfg(unix)]
{
let mut attr: pthread_attr_t = zeroed();
let mut thread: pthread_t = 0;
unsafe {
#[cfg(unix)]
{
let mut attr: pthread_attr_t = zeroed();
let mut thread: pthread_t = 0;
if pthread_attr_init(&mut attr) != 0 {
assert!(false);
if pthread_attr_init(&mut attr) != 0 {
assert!(false);
}
if pthread_create(&mut thread, &attr, f, 0 as *mut c_void) != 0 {
assert!(false);
}
Thread { handle: thread }
}
if pthread_create(&mut thread, &attr, f, 0 as *mut c_void) != 0 {
assert!(false);
#[cfg(windows)]
{
let handle =
CreateThread(0 as *mut c_void, 0, f, 0 as *mut c_void, 0, 0 as *mut u32);
if (handle as u64) == 0 {
assert!(false);
}
Thread { handle }
}
Thread { handle: thread }
}
#[cfg(windows)]
{
let handle = CreateThread(0 as *mut c_void, 0, f, 0 as *mut c_void, 0, 0 as *mut u32);
if (handle as u64) == 0 {
assert!(false);
}
Thread { handle }
}
}
unsafe fn join(self) {
#[cfg(unix)]
{
let mut res = 0 as *mut c_void;
pthread_join(self.handle, &mut res);
}
unsafe {
#[cfg(unix)]
{
let mut res = 0 as *mut c_void;
pthread_join(self.handle, &mut res);
}
#[cfg(windows)]
{
// The INFINITE macro is used to signal operations that do not timeout.
let infinite = 0xffffffff;
assert!(WaitForSingleObject(self.handle, infinite) == 0);
#[cfg(windows)]
{
// The INFINITE macro is used to signal operations that do not timeout.
let infinite = 0xffffffff;
assert!(WaitForSingleObject(self.handle, infinite) == 0);
}
}
}
}