Skip to content

Commit 684d5ed

Browse files
committed
[WIP] Migrate all tests to the 2024 edition
1 parent 53bbef8 commit 684d5ed

File tree

9 files changed

+75
-278
lines changed

9 files changed

+75
-278
lines changed

.vscode/settings.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
"crates": [
1616
{
1717
"root_module": "./example/mini_core.rs",
18-
"edition": "2018",
18+
"edition": "2024",
1919
"deps": [],
2020
"cfg": [],
2121
},
2222
{
2323
"root_module": "./example/mini_core_hello_world.rs",
24-
"edition": "2018",
24+
"edition": "2024",
2525
"deps": [{ "crate": 0, "name": "mini_core" }],
2626
"cfg": [],
2727
},
2828
{
2929
"root_module": "./example/mod_bench.rs",
30-
"edition": "2018",
30+
"edition": "2024",
3131
"deps": [],
3232
"cfg": [],
3333
},
@@ -38,7 +38,7 @@
3838
"crates": [
3939
{
4040
"root_module": "./example/std_example.rs",
41-
"edition": "2015",
41+
"edition": "2024",
4242
"deps": [],
4343
"cfg": [],
4444
},

build_system/tests.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
7373
"example/arbitrary_self_types_pointers_and_wrappers.rs",
7474
&[],
7575
),
76-
TestCase::build_lib("build.alloc_system", "example/alloc_system.rs", "lib"),
77-
TestCase::build_bin_and_run("aot.alloc_example", "example/alloc_example.rs", &[]),
7876
TestCase::jit_bin("jit.std_example", "example/std_example.rs", "arg"),
7977
TestCase::build_bin_and_run("aot.std_example", "example/std_example.rs", &["arg"]),
8078
TestCase::build_bin_and_run("aot.dst_field_align", "example/dst-field-align.rs", &[]),
@@ -89,19 +87,10 @@ const BASE_SYSROOT_SUITE: &[TestCase] = &[
8987
&[],
9088
),
9189
TestCase::build_bin_and_run("aot.float-minmax-pass", "example/float-minmax-pass.rs", &[]),
92-
TestCase::build_bin_and_run("aot.mod_bench", "example/mod_bench.rs", &[]),
9390
TestCase::build_bin_and_run("aot.issue-72793", "example/issue-72793.rs", &[]),
9491
TestCase::build_bin("aot.issue-59326", "example/issue-59326.rs"),
9592
TestCase::build_bin_and_run("aot.neon", "example/neon.rs", &[]),
96-
TestCase::custom("aot.gen_block_iterate", &|runner| {
97-
runner.run_rustc([
98-
"example/gen_block_iterate.rs",
99-
"--edition",
100-
"2024",
101-
"-Zunstable-options",
102-
]);
103-
runner.run_out_command("gen_block_iterate", &[]);
104-
}),
93+
TestCase::build_bin_and_run("aot.gen_block_iterate", "example/gen_block_iterate.rs", &[]),
10594
TestCase::build_bin_and_run("aot.raw-dylib", "example/raw-dylib.rs", &[]),
10695
];
10796

@@ -431,6 +420,7 @@ impl<'a> TestRunner<'a> {
431420
cmd.arg(&self.target_compiler.triple);
432421
cmd.arg("-Cpanic=abort");
433422
cmd.arg("--check-cfg=cfg(jit)");
423+
cmd.arg("--edition=2024");
434424
cmd.args(args);
435425
cmd
436426
}

config.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,12 @@ aot.mini_core_hello_world
2121
testsuite.base_sysroot
2222
aot.arbitrary_self_types_pointers_and_wrappers
2323
aot.issue_91827_extern_types
24-
build.alloc_system
25-
aot.alloc_example
2624
jit.std_example
2725
aot.std_example
2826
aot.dst_field_align
2927
aot.subslice-patterns-const-eval
3028
aot.track-caller-attribute
3129
aot.float-minmax-pass
32-
aot.mod_bench
3330
aot.issue-72793
3431
aot.issue-59326
3532
aot.neon

example/alloc_example.rs

Lines changed: 0 additions & 44 deletions
This file was deleted.

example/alloc_system.rs

Lines changed: 0 additions & 124 deletions
This file was deleted.

example/example.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,16 @@ pub fn use_size_of() -> usize {
8181
}
8282

8383
pub unsafe fn use_copy_intrinsic(src: *const u8, dst: *mut u8) {
84-
intrinsics::copy::<u8>(src, dst, 1);
84+
unsafe {
85+
intrinsics::copy::<u8>(src, dst, 1);
86+
}
8587
}
8688

8789
pub unsafe fn use_copy_intrinsic_ref(src: *const u8, dst: *mut u8) {
88-
let copy2 = &intrinsics::copy::<u8>;
89-
copy2(src, dst, 1);
90+
unsafe {
91+
let copy2 = &intrinsics::copy::<u8>;
92+
copy2(src, dst, 1);
93+
}
9094
}
9195

9296
pub const ABC: u8 = 6 * 7;
@@ -130,11 +134,11 @@ pub fn eq_char(a: char, b: char) -> bool {
130134
}
131135

132136
pub unsafe fn transmute(c: char) -> u32 {
133-
intrinsics::transmute(c)
137+
unsafe { intrinsics::transmute(c) }
134138
}
135139

136140
pub unsafe fn deref_str_ptr(s: *const str) -> &'static str {
137-
&*s
141+
unsafe { &*s }
138142
}
139143

140144
pub fn use_array(arr: [u8; 3]) -> u8 {
@@ -150,7 +154,7 @@ pub fn array_as_slice(arr: &[u8; 3]) -> &[u8] {
150154
}
151155

152156
pub unsafe fn use_ctlz_nonzero(a: u16) -> u32 {
153-
intrinsics::ctlz_nonzero(a)
157+
unsafe { intrinsics::ctlz_nonzero(a) }
154158
}
155159

156160
pub fn ptr_as_usize(ptr: *const u8) -> usize {

example/mini_core.rs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,9 @@ fn eh_personality() -> ! {
527527
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {
528528
// Code here does not matter - this is replaced by the
529529
// real drop glue by the compiler.
530-
drop_in_place(to_drop);
530+
unsafe {
531+
drop_in_place(to_drop);
532+
}
531533
}
532534

533535
#[lang = "unpin"]
@@ -594,7 +596,7 @@ impl<T: ?Sized> Deref for Box<T> {
594596

595597
#[lang = "exchange_malloc"]
596598
unsafe fn allocate(size: usize, _align: usize) -> *mut u8 {
597-
libc::malloc(size)
599+
unsafe { libc::malloc(size) }
598600
}
599601

600602
#[lang = "drop"]
@@ -616,6 +618,8 @@ pub union MaybeUninit<T> {
616618
}
617619

618620
pub mod intrinsics {
621+
use super::*;
622+
619623
#[rustc_intrinsic]
620624
#[rustc_intrinsic_must_be_overridden]
621625
pub fn abort() -> ! {
@@ -628,7 +632,7 @@ pub mod intrinsics {
628632
}
629633
#[rustc_intrinsic]
630634
#[rustc_intrinsic_must_be_overridden]
631-
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize {
635+
pub unsafe fn size_of_val<T: ?Sized>(_val: *const T) -> usize {
632636
loop {}
633637
}
634638
#[rustc_intrinsic]
@@ -638,7 +642,7 @@ pub mod intrinsics {
638642
}
639643
#[rustc_intrinsic]
640644
#[rustc_intrinsic_must_be_overridden]
641-
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize {
645+
pub unsafe fn min_align_of_val<T: ?Sized>(_val: *const T) -> usize {
642646
loop {}
643647
}
644648
#[rustc_intrinsic]
@@ -658,7 +662,7 @@ pub mod intrinsics {
658662
}
659663
#[rustc_intrinsic]
660664
#[rustc_intrinsic_must_be_overridden]
661-
pub fn needs_drop<T: ?::Sized>() -> bool {
665+
pub fn needs_drop<T: ?Sized>() -> bool {
662666
loop {}
663667
}
664668
#[rustc_intrinsic]
@@ -689,13 +693,13 @@ pub mod libc {
689693
// symbols to link against.
690694
#[cfg_attr(unix, link(name = "c"))]
691695
#[cfg_attr(target_env = "msvc", link(name = "legacy_stdio_definitions"))]
692-
extern "C" {
696+
unsafe extern "C" {
693697
pub fn printf(format: *const i8, ...) -> i32;
694698
}
695699

696700
#[cfg_attr(unix, link(name = "c"))]
697701
#[cfg_attr(target_env = "msvc", link(name = "msvcrt"))]
698-
extern "C" {
702+
unsafe extern "C" {
699703
pub fn puts(s: *const i8) -> i32;
700704
pub fn malloc(size: usize) -> *mut u8;
701705
pub fn free(ptr: *mut u8);
@@ -727,7 +731,7 @@ impl<T> Index<usize> for [T] {
727731
}
728732
}
729733

730-
extern "C" {
734+
unsafe extern "C" {
731735
type VaListImpl;
732736
}
733737

@@ -786,7 +790,7 @@ struct PanicLocation {
786790
column: u32,
787791
}
788792

789-
#[no_mangle]
793+
#[unsafe(no_mangle)]
790794
#[cfg(not(all(windows, target_env = "gnu")))]
791795
pub fn get_tls() -> u8 {
792796
#[thread_local]

0 commit comments

Comments
 (0)