From b8ea4628aa7442565ec9e17e9656ac30479f6f09 Mon Sep 17 00:00:00 2001 From: g4titanx Date: Mon, 30 Dec 2024 22:42:13 +0100 Subject: [PATCH 1/3] feat: import minicore --- CONTRIBUTING.md | 113 +++++++++++++++ tests/run/abort1.rs | 29 +--- tests/run/abort2.rs | 29 +--- tests/run/array.rs | 213 ++------------------------- tests/run/assign.rs | 122 ++-------------- tests/run/closure.rs | 190 ++---------------------- tests/run/condition.rs | 295 ++------------------------------------ tests/run/empty_main.rs | 20 +-- tests/run/exit.rs | 26 ++-- tests/run/exit_code.rs | 26 ++-- tests/run/fun_ptr.rs | 202 ++------------------------ tests/run/mut_ref.rs | 121 ++-------------- tests/run/operations.rs | 223 ++-------------------------- tests/run/ptr_cast.rs | 201 ++------------------------ tests/run/return-tuple.rs | 43 ++---- tests/run/slice.rs | 107 ++------------ tests/run/static.rs | 63 ++------ tests/run/structs.rs | 31 ++-- tests/run/tuple.rs | 31 ++-- 19 files changed, 285 insertions(+), 1800 deletions(-) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..3bddb6ac63b --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,113 @@ +# Contributing to rust_codegen_gcc + +Welcome to the rust_codegen_gcc project! This guide will help you get started as a contributor. The project aims to provide a GCC codegen backend for rustc, allowing Rust compilation on platforms unsupported by LLVM and potentially improving runtime performance through GCC's optimizations. + +## Getting Started + +### Setting Up Your Development Environment + +1. Install the required dependencies: + - rustup (follow instructions on the [official website](https://rustup.rs)) + - DejaGnu (for running libgccjit test suite) + - Additional packages: `flex`, `libmpfr-dev`, `libgmp-dev`, `libmpc3`, `libmpc-dev` + +2. Clone and configure the repository: + ```bash + git clone https://github.com/rust-lang/rust_codegen_gcc + cd rust_codegen_gcc + cp config.example.toml config.toml + ``` + +3. Build the project: + ```bash + ./y.sh prepare # downloads and patches sysroot + ./y.sh build --sysroot --release + ``` + +### Running Tests + +To verify your setup: +```bash +# Run the full test suite +./y.sh test --release + +# Test with a simple program +./y.sh cargo build --manifest-path tests/hello-world/Cargo.toml +``` + +## Communication Channels + +- Matrix: Join our [Matrix channel](https://matrix.to/#/#rustc_codegen_gcc:matrix.org) +- IRC: Join us on [IRC](https://web.libera.chat/#rustc_codegen_gcc) +- GitHub Issues: For bug reports and feature discussions + +We encourage new contributors to join our communication channels and introduce themselves. Feel free to ask questions about where to start or discuss potential contributions. + +## Understanding Core Concepts + +### Project Structure + +The project consists of several key components: +- The GCC backend integration through libgccjit +- Rust compiler interface +- Test infrastructure + +### Common Development Tasks + +#### Running Specific Tests +To run a specific test: +1. Individual test: `./y.sh test --test ` +2. libgccjit tests: + ```bash + cd gcc-build/gcc + make check-jit + # For a specific test: + make check-jit RUNTESTFLAGS="-v -v -v jit.exp=jit.dg/test-asm.cc" + ``` + +#### Debugging Tools +The project provides several environment variables for debugging: +- `CG_GCCJIT_DUMP_MODULE`: Dumps a specific module +- `CG_GCCJIT_DUMP_TO_FILE`: Creates C-like representation +- `CG_GCCJIT_DUMP_RTL`: Shows Register Transfer Language output + +Full list of debugging options can be found in the README. + +## Making Contributions + +### Finding Issues to Work On +1. Look for issues labeled with `good-first-issue` or `help-wanted` +2. Check the project roadmap for larger initiatives +3. Consider improving documentation or tests + +### Pull Request Process +1. Fork the repository and create a new branch +2. Make your changes with clear commit messages +3. Add tests for new functionality +4. Update documentation as needed +5. Submit a PR with a description of your changes + +### Code Style Guidelines +- Follow Rust standard coding conventions +- Ensure your code passes `rustfmt` and `clippy` +- Add comments explaining complex logic, especially in GCC interface code + +## Additional Resources + +- [Rustc Dev Guide](https://rustc-dev-guide.rust-lang.org/) +- [GCC Internals Documentation](https://gcc.gnu.org/onlinedocs/gccint/) +- Project-specific documentation in the `doc/` directory: + - Common errors + - Debugging GCC LTO + - Git subtree sync + - Sending patches to GCC + +## Getting Help + +If you're stuck or unsure about anything: +1. Check the existing documentation in the `doc/` directory +2. Ask in the IRC or Matrix channels +3. Open a GitHub issue for technical problems +4. Comment on the issue you're working on if you need guidance + +Remember that all contributions, including documentation improvements, bug reports, and feature requests, are valuable to the project. \ No newline at end of file diff --git a/tests/run/abort1.rs b/tests/run/abort1.rs index 44297e12779..30569f8c8da 100644 --- a/tests/run/abort1.rs +++ b/tests/run/abort1.rs @@ -3,7 +3,7 @@ // Run-time: // status: signal -#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -13,31 +13,8 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod intrinsics { - use super::Sized; - - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} +extern crate mini_core; +use mini_core::{intrinsics, Sized, Copy, Receiver, Freeze}; /* * Code diff --git a/tests/run/abort2.rs b/tests/run/abort2.rs index ce816927123..cba23e595df 100644 --- a/tests/run/abort2.rs +++ b/tests/run/abort2.rs @@ -3,7 +3,7 @@ // Run-time: // status: signal -#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -13,31 +13,8 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod intrinsics { - use super::Sized; - - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} + extern crate mini_core; + use mini_core::{intrinsics, Sized, Copy, Receiver, Freeze}; /* * Code diff --git a/tests/run/array.rs b/tests/run/array.rs index 432f11ad8d4..edfa7d614c8 100644 --- a/tests/run/array.rs +++ b/tests/run/array.rs @@ -7,7 +7,7 @@ // 5 // 10 -#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -17,206 +17,17 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for usize {} -impl Copy for i32 {} -impl Copy for u8 {} -impl Copy for i8 {} -impl Copy for i16 {} -impl Copy for *mut T {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - pub fn puts(s: *const u8) -> i32; - } -} - -#[lang = "index"] -pub trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -impl Index for [T; 3] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -impl Index for [T] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place(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); -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - intrinsics::abort(); - } -} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -#[lang = "panic_bounds_check"] -#[track_caller] -#[no_mangle] -fn panic_bounds_check(index: usize, len: usize) -> ! { - unsafe { - libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index); - intrinsics::abort(); - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[lang = "sub"] -pub trait Sub { - type Output; - - fn sub(self, rhs: RHS) -> Self::Output; -} - -impl Sub for usize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for isize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for u8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i16 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -#[track_caller] -#[lang = "panic_const_add_overflow"] -pub fn panic_const_add_overflow() -> ! { - panic("attempt to add with overflow"); -} - -#[track_caller] -#[lang = "panic_const_sub_overflow"] -pub fn panic_const_sub_overflow() -> ! { - panic("attempt to subtract with overflow"); -} +extern crate mini_core; +use mini_core::{ + libc, + Index, + Add, Sub, + Sized, + Copy, + Receiver, + Freeze, + intrinsics, +}; /* * Code diff --git a/tests/run/assign.rs b/tests/run/assign.rs index e105d64a8ad..33c5cd9a95b 100644 --- a/tests/run/assign.rs +++ b/tests/run/assign.rs @@ -6,7 +6,7 @@ // 10 #![allow(internal_features, unused_attributes)] -#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs, track_caller)] +#![feature(no_core, start)] #![no_std] #![no_core] @@ -15,116 +15,18 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} +extern crate mini_core; +use mini_core::{ + libc, + intrinsics, + Sized, + Copy, + Receiver, + Freeze, + Add, + panic +}; -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for *mut i32 {} -impl Copy for usize {} -impl Copy for u8 {} -impl Copy for i8 {} -impl Copy for i32 {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn puts(s: *const u8) -> i32; - pub fn fflush(stream: *mut i32) -> i32; - pub fn printf(format: *const i8, ...) -> i32; - - pub static stdout: *mut i32; - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - libc::fflush(libc::stdout); - intrinsics::abort(); - } -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[track_caller] -#[lang = "panic_const_add_overflow"] -pub fn panic_const_add_overflow() -> ! { - panic("attempt to add with overflow"); -} /* * Code diff --git a/tests/run/closure.rs b/tests/run/closure.rs index 00e61cc001f..df32df43902 100644 --- a/tests/run/closure.rs +++ b/tests/run/closure.rs @@ -8,8 +8,7 @@ // Int argument: 2 // Both args: 11 -#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, - unboxed_closures, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -19,182 +18,17 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for usize {} -impl Copy for i32 {} -impl Copy for u32 {} -impl Copy for u8 {} -impl Copy for i8 {} -impl Copy for *mut T {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn puts(s: *const u8) -> i32; - pub fn printf(format: *const i8, ...) -> i32; - } -} - -#[lang = "index"] -pub trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -impl Index for [T; 3] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -impl Index for [T] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place(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); -} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -#[lang = "panic_bounds_check"] -#[track_caller] -#[no_mangle] -fn panic_bounds_check(index: usize, len: usize) -> ! { - unsafe { - libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index); - intrinsics::abort(); - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "tuple_trait"] -pub trait Tuple {} - -#[lang = "unsize"] -pub trait Unsize {} - -#[lang = "coerce_unsized"] -pub trait CoerceUnsized {} - -impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} -impl<'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {} -impl, U: ?Sized> CoerceUnsized<*const U> for *const T {} -impl, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} - -#[lang = "fn_once"] -#[rustc_paren_sugar] -pub trait FnOnce { - #[lang = "fn_once_output"] - type Output; - - extern "rust-call" fn call_once(self, args: Args) -> Self::Output; -} - -#[lang = "fn_mut"] -#[rustc_paren_sugar] -pub trait FnMut: FnOnce { - extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - intrinsics::abort(); - } -} - -#[track_caller] -#[lang = "panic_const_add_overflow"] -pub fn panic_const_add_overflow() -> ! { - panic("attempt to add with overflow"); -} +extern crate mini_core; +use mini_core::{ + libc, + FnOnce, + FnMut, + Tuple, + Add, + Sized, + Unsize, + CoerceUnsized +}; /* * Code diff --git a/tests/run/condition.rs b/tests/run/condition.rs index 7b05b7decd3..8359cbc8d2c 100644 --- a/tests/run/condition.rs +++ b/tests/run/condition.rs @@ -5,7 +5,7 @@ // stdout: true // 1 -#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -15,287 +15,18 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for usize {} -impl Copy for u64 {} -impl Copy for i32 {} -impl Copy for u32 {} -impl Copy for bool {} -impl Copy for u16 {} -impl Copy for i16 {} -impl Copy for char {} -impl Copy for i8 {} -impl Copy for u8 {} -impl Copy for *mut T {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - pub fn puts(s: *const u8) -> i32; - } -} - -#[lang = "index"] -pub trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -impl Index for [T; 3] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -impl Index for [T] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place(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); -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - intrinsics::abort(); - } -} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -#[lang = "panic_bounds_check"] -#[track_caller] -#[no_mangle] -fn panic_bounds_check(index: usize, len: usize) -> ! { - unsafe { - libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index); - intrinsics::abort(); - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[lang = "sub"] -pub trait Sub { - type Output; - - fn sub(self, rhs: RHS) -> Self::Output; -} - -impl Sub for usize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for isize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for u8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i16 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -#[lang = "eq"] -pub trait PartialEq { - fn eq(&self, other: &Rhs) -> bool; - fn ne(&self, other: &Rhs) -> bool; -} - -impl PartialEq for u8 { - fn eq(&self, other: &u8) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &u8) -> bool { - (*self) != (*other) - } -} - -impl PartialEq for u16 { - fn eq(&self, other: &u16) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &u16) -> bool { - (*self) != (*other) - } -} - -impl PartialEq for u32 { - fn eq(&self, other: &u32) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &u32) -> bool { - (*self) != (*other) - } -} - - -impl PartialEq for u64 { - fn eq(&self, other: &u64) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &u64) -> bool { - (*self) != (*other) - } -} - -impl PartialEq for usize { - fn eq(&self, other: &usize) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &usize) -> bool { - (*self) != (*other) - } -} - -impl PartialEq for i8 { - fn eq(&self, other: &i8) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &i8) -> bool { - (*self) != (*other) - } -} - -impl PartialEq for i32 { - fn eq(&self, other: &i32) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &i32) -> bool { - (*self) != (*other) - } -} - -impl PartialEq for isize { - fn eq(&self, other: &isize) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &isize) -> bool { - (*self) != (*other) - } -} - -impl PartialEq for char { - fn eq(&self, other: &char) -> bool { - (*self) == (*other) - } - fn ne(&self, other: &char) -> bool { - (*self) != (*other) - } -} +extern crate mini_core; +use mini_core::{ + libc, + Sized, + Copy, + PartialEq, + Add, + Sub, + Index, + Receiver, + Freeze, +}; /* * Code diff --git a/tests/run/empty_main.rs b/tests/run/empty_main.rs index e66a859ad69..b21b5a20759 100644 --- a/tests/run/empty_main.rs +++ b/tests/run/empty_main.rs @@ -3,7 +3,7 @@ // Run-time: // status: 0 -#![feature(auto_traits, lang_items, no_core, start)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -13,22 +13,8 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} +extern crate mini_core; +use mini_core::{Sized, Copy, Receiver, Freeze}; /* * Code diff --git a/tests/run/exit.rs b/tests/run/exit.rs index bf1cbeef302..cb7158be029 100644 --- a/tests/run/exit.rs +++ b/tests/run/exit.rs @@ -3,7 +3,7 @@ // Run-time: // status: 2 -#![feature(auto_traits, lang_items, no_core, start, intrinsics)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -20,22 +20,14 @@ mod libc { * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} +extern crate mini_core; +use mini_core::{ + libc, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code diff --git a/tests/run/exit_code.rs b/tests/run/exit_code.rs index be7a233efda..477659da077 100644 --- a/tests/run/exit_code.rs +++ b/tests/run/exit_code.rs @@ -3,7 +3,7 @@ // Run-time: // status: 1 -#![feature(auto_traits, lang_items, no_core, start)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -13,22 +13,14 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} +extern crate mini_core; +use mini_core::{ + libc, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code diff --git a/tests/run/fun_ptr.rs b/tests/run/fun_ptr.rs index 4e96f376555..92462bbacac 100644 --- a/tests/run/fun_ptr.rs +++ b/tests/run/fun_ptr.rs @@ -4,7 +4,7 @@ // status: 0 // stdout: 1 -#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -14,195 +14,17 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for usize {} -impl Copy for i32 {} -impl Copy for u8 {} -impl Copy for i8 {} -impl Copy for i16 {} -impl Copy for *mut T {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - pub fn puts(s: *const u8) -> i32; - } -} - -#[lang = "index"] -pub trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -impl Index for [T; 3] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -impl Index for [T] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place(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); -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - intrinsics::abort(); - } -} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -#[lang = "panic_bounds_check"] -#[track_caller] -#[no_mangle] -fn panic_bounds_check(index: usize, len: usize) -> ! { - unsafe { - libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index); - intrinsics::abort(); - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[lang = "sub"] -pub trait Sub { - type Output; - - fn sub(self, rhs: RHS) -> Self::Output; -} - -impl Sub for usize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for isize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for u8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i16 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - +extern crate mini_core; +use mini_core::{ + libc, + Add, + Sub, + Index, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code diff --git a/tests/run/mut_ref.rs b/tests/run/mut_ref.rs index 5a3f72b6904..afe09699799 100644 --- a/tests/run/mut_ref.rs +++ b/tests/run/mut_ref.rs @@ -8,7 +8,7 @@ // 11 #![allow(internal_features, unused_attributes)] -#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs, track_caller)] +#![feature(no_core, start)] #![no_std] #![no_core] @@ -17,116 +17,15 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for *mut i32 {} -impl Copy for usize {} -impl Copy for u8 {} -impl Copy for i8 {} -impl Copy for i32 {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn puts(s: *const u8) -> i32; - pub fn fflush(stream: *mut i32) -> i32; - pub fn printf(format: *const i8, ...) -> i32; - - pub static stdout: *mut i32; - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - libc::fflush(libc::stdout); - intrinsics::abort(); - } -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[track_caller] -#[lang = "panic_const_add_overflow"] -pub fn panic_const_add_overflow() -> ! { - panic("attempt to add with overflow"); -} +extern crate mini_core; +use mini_core::{ + libc, + Add, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code diff --git a/tests/run/operations.rs b/tests/run/operations.rs index d697bd921cd..4f21c14bee7 100644 --- a/tests/run/operations.rs +++ b/tests/run/operations.rs @@ -6,7 +6,7 @@ // 10 #![allow(internal_features, unused_attributes)] -#![feature(auto_traits, lang_items, no_core, start, intrinsics, arbitrary_self_types, rustc_attrs)] +#![feature(no_core, start)] #![no_std] #![no_core] @@ -15,215 +15,18 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for *mut i32 {} -impl Copy for usize {} -impl Copy for u8 {} -impl Copy for i8 {} -impl Copy for i16 {} -impl Copy for i32 {} - -#[lang = "deref"] -pub trait Deref { - type Target: ?Sized; - - fn deref(&self) -> &Self::Target; -} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - pub fn puts(s: *const u8) -> i32; - pub fn fflush(stream: *mut i32) -> i32; - - pub static stdout: *mut i32; - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - libc::fflush(libc::stdout); - intrinsics::abort(); - } -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[lang = "sub"] -pub trait Sub { - type Output; - - fn sub(self, rhs: RHS) -> Self::Output; -} - -impl Sub for usize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for isize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for u8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i16 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -#[lang = "mul"] -pub trait Mul { - type Output; - - #[must_use] - fn mul(self, rhs: RHS) -> Self::Output; -} - -impl Mul for u8 { - type Output = Self; - - fn mul(self, rhs: Self) -> Self::Output { - self * rhs - } -} - -impl Mul for usize { - type Output = Self; - - fn mul(self, rhs: Self) -> Self::Output { - self * rhs - } -} - -impl Mul for isize { - type Output = Self; - - fn mul(self, rhs: Self) -> Self::Output { - self * rhs - } -} - -#[track_caller] -#[lang = "panic_const_add_overflow"] -pub fn panic_const_add_overflow() -> ! { - panic("attempt to add with overflow"); -} - -#[track_caller] -#[lang = "panic_const_sub_overflow"] -pub fn panic_const_sub_overflow() -> ! { - panic("attempt to subtract with overflow"); -} - -#[track_caller] -#[lang = "panic_const_mul_overflow"] -pub fn panic_const_mul_overflow() -> ! { - panic("attempt to multiply with overflow"); -} +extern crate mini_core; +use mini_core::{ + libc, + Add, + Sub, + Mul, + Deref, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code diff --git a/tests/run/ptr_cast.rs b/tests/run/ptr_cast.rs index a94279182d6..d3ed4d47103 100644 --- a/tests/run/ptr_cast.rs +++ b/tests/run/ptr_cast.rs @@ -4,7 +4,7 @@ // status: 0 // stdout: 1 -#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -14,194 +14,17 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for usize {} -impl Copy for i32 {} -impl Copy for u8 {} -impl Copy for i8 {} -impl Copy for i16 {} -impl Copy for *mut T {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - pub fn puts(s: *const u8) -> i32; - } -} - -#[lang = "index"] -pub trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -impl Index for [T; 3] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -impl Index for [T] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place(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); -} - -#[lang = "panic"] -#[track_caller] -#[no_mangle] -pub fn panic(_msg: &'static str) -> ! { - unsafe { - libc::puts("Panicking\0" as *const str as *const u8); - intrinsics::abort(); - } -} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -#[lang = "panic_bounds_check"] -#[track_caller] -#[no_mangle] -fn panic_bounds_check(index: usize, len: usize) -> ! { - unsafe { - libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index); - intrinsics::abort(); - } -} - -mod intrinsics { - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -#[lang = "add"] -trait Add { - type Output; - - fn add(self, rhs: RHS) -> Self::Output; -} - -impl Add for u8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i8 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for i32 { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for usize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -impl Add for isize { - type Output = Self; - - fn add(self, rhs: Self) -> Self { - self + rhs - } -} - -#[lang = "sub"] -pub trait Sub { - type Output; - - fn sub(self, rhs: RHS) -> Self::Output; -} - -impl Sub for usize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for isize { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for u8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i8 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} - -impl Sub for i16 { - type Output = Self; - - fn sub(self, rhs: Self) -> Self { - self - rhs - } -} +extern crate mini_core; +use mini_core::{ + libc, + Add, + Sub, + Index, + Sized, + Copy, + Receiver, + Freeze +}; /* diff --git a/tests/run/return-tuple.rs b/tests/run/return-tuple.rs index 8d40deb8c85..a6591a74aec 100644 --- a/tests/run/return-tuple.rs +++ b/tests/run/return-tuple.rs @@ -6,49 +6,24 @@ // 10 // 42 -#![feature(auto_traits, lang_items, no_core, start, intrinsics)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] #![no_core] -#[lang = "copy"] -pub unsafe trait Copy {} - -unsafe impl Copy for bool {} -unsafe impl Copy for u8 {} -unsafe impl Copy for u16 {} -unsafe impl Copy for u32 {} -unsafe impl Copy for u64 {} -unsafe impl Copy for usize {} -unsafe impl Copy for i8 {} -unsafe impl Copy for i16 {} -unsafe impl Copy for i32 {} -unsafe impl Copy for isize {} -unsafe impl Copy for f32 {} -unsafe impl Copy for char {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - } -} - /* * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} +extern crate mini_core; +use mini_core::{ + libc, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code diff --git a/tests/run/slice.rs b/tests/run/slice.rs index e86fc823a1a..34bcb2cb444 100644 --- a/tests/run/slice.rs +++ b/tests/run/slice.rs @@ -4,7 +4,7 @@ // status: 0 // stdout: 5 -#![feature(arbitrary_self_types, auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -14,100 +14,17 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for usize {} -impl Copy for i32 {} -impl Copy for u32 {} -impl Copy for *mut T {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - } -} - -#[lang = "index"] -pub trait Index { - type Output: ?Sized; - fn index(&self, index: Idx) -> &Self::Output; -} - -impl Index for [T; 3] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -impl Index for [T] { - type Output = T; - - fn index(&self, index: usize) -> &Self::Output { - &self[index] - } -} - -#[lang = "unsize"] -pub trait Unsize {} - -#[lang = "coerce_unsized"] -pub trait CoerceUnsized {} - -impl<'a, 'b: 'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a U> for &'b T {} -impl<'a, T: ?Sized + Unsize, U: ?Sized> CoerceUnsized<&'a mut U> for &'a mut T {} -impl, U: ?Sized> CoerceUnsized<*const U> for *const T {} -impl, U: ?Sized> CoerceUnsized<*mut U> for *mut T {} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place(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); -} - -#[lang = "panic_location"] -struct PanicLocation { - file: &'static str, - line: u32, - column: u32, -} - -#[lang = "panic_bounds_check"] -#[track_caller] -#[no_mangle] -fn panic_bounds_check(index: usize, len: usize) -> ! { - unsafe { - libc::printf("index out of bounds: the len is %d but the index is %d\n\0" as *const str as *const i8, len, index); - intrinsics::abort(); - } -} - -mod intrinsics { - use super::Sized; - - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} +extern crate mini_core; +use mini_core::{ + libc, + Index, + Sized, + Copy, + Receiver, + Freeze, + Unsize, + CoerceUnsized +}; /* * Code diff --git a/tests/run/static.rs b/tests/run/static.rs index 6247e08f5e3..e662d802b41 100644 --- a/tests/run/static.rs +++ b/tests/run/static.rs @@ -9,7 +9,7 @@ // 12 // 1 -#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] +#![feature(no_core, start)] #![allow(internal_features)] #![no_std] @@ -19,56 +19,17 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "destruct"] -pub trait Destruct {} - -#[lang = "drop"] -pub trait Drop {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} -impl Copy for *mut T {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod intrinsics { - use super::Sized; - - extern "rust-intrinsic" { - #[rustc_safe_intrinsic] - pub fn abort() -> !; - } -} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - } -} - -#[lang = "structural_peq"] -pub trait StructuralPartialEq {} - -#[lang = "drop_in_place"] -#[allow(unconditional_recursion)] -pub unsafe fn drop_in_place(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); -} +extern crate mini_core; +use mini_core::{ + libc, + Sized, + Copy, + Receiver, + Freeze, + Destruct, + Drop, + StructuralPartialEq +}; /* * Code diff --git a/tests/run/structs.rs b/tests/run/structs.rs index d6455667400..b413b3e951f 100644 --- a/tests/run/structs.rs +++ b/tests/run/structs.rs @@ -15,29 +15,14 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - } -} +extern crate mini_core; +use mini_core::{ + libc, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code diff --git a/tests/run/tuple.rs b/tests/run/tuple.rs index 8a7d85ae867..875983fabda 100644 --- a/tests/run/tuple.rs +++ b/tests/run/tuple.rs @@ -14,29 +14,14 @@ * Core */ -// Because we don't have core yet. -#[lang = "sized"] -pub trait Sized {} - -#[lang = "copy"] -trait Copy { -} - -impl Copy for isize {} - -#[lang = "receiver"] -trait Receiver { -} - -#[lang = "freeze"] -pub(crate) unsafe auto trait Freeze {} - -mod libc { - #[link(name = "c")] - extern "C" { - pub fn printf(format: *const i8, ...) -> i32; - } -} +extern crate mini_core; +use mini_core::{ + libc, + Sized, + Copy, + Receiver, + Freeze +}; /* * Code From a75ea9f32767ff2cbbd822099202af001ea259e7 Mon Sep 17 00:00:00 2001 From: g4titanx Date: Fri, 3 Jan 2025 08:30:27 +0100 Subject: [PATCH 2/3] use include instead --- tests/run/abort1.rs | 7 +------ tests/run/abort2.rs | 7 +------ tests/run/array.rs | 16 +--------------- tests/run/assign.rs | 17 +---------------- tests/run/closure.rs | 16 +--------------- tests/run/condition.rs | 17 +---------------- tests/run/empty_main.rs | 7 +------ tests/run/exit.rs | 13 +------------ tests/run/exit_code.rs | 13 +------------ tests/run/fun_ptr.rs | 16 +--------------- tests/run/mut_ref.rs | 14 +------------- tests/run/operations.rs | 17 +---------------- tests/run/ptr_cast.rs | 17 +---------------- tests/run/return-tuple.rs | 13 +------------ tests/run/slice.rs | 16 +--------------- tests/run/static.rs | 16 +--------------- tests/run/structs.rs | 13 +------------ tests/run/tuple.rs | 13 +------------ 18 files changed, 18 insertions(+), 230 deletions(-) diff --git a/tests/run/abort1.rs b/tests/run/abort1.rs index 30569f8c8da..5d2b6e4cc2f 100644 --- a/tests/run/abort1.rs +++ b/tests/run/abort1.rs @@ -9,12 +9,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{intrinsics, Sized, Copy, Receiver, Freeze}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/abort2.rs b/tests/run/abort2.rs index cba23e595df..d15319b765a 100644 --- a/tests/run/abort2.rs +++ b/tests/run/abort2.rs @@ -9,12 +9,7 @@ #![no_std] #![no_core] -/* - * Core - */ - - extern crate mini_core; - use mini_core::{intrinsics, Sized, Copy, Receiver, Freeze}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/array.rs b/tests/run/array.rs index edfa7d614c8..78aa921767c 100644 --- a/tests/run/array.rs +++ b/tests/run/array.rs @@ -13,21 +13,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Index, - Add, Sub, - Sized, - Copy, - Receiver, - Freeze, - intrinsics, -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/assign.rs b/tests/run/assign.rs index 33c5cd9a95b..c86857660a7 100644 --- a/tests/run/assign.rs +++ b/tests/run/assign.rs @@ -11,22 +11,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - intrinsics, - Sized, - Copy, - Receiver, - Freeze, - Add, - panic -}; - +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/closure.rs b/tests/run/closure.rs index df32df43902..7e70cadcdc3 100644 --- a/tests/run/closure.rs +++ b/tests/run/closure.rs @@ -14,21 +14,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - FnOnce, - FnMut, - Tuple, - Add, - Sized, - Unsize, - CoerceUnsized -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/condition.rs b/tests/run/condition.rs index 8359cbc8d2c..16df95c3dc2 100644 --- a/tests/run/condition.rs +++ b/tests/run/condition.rs @@ -11,22 +11,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Sized, - Copy, - PartialEq, - Add, - Sub, - Index, - Receiver, - Freeze, -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/empty_main.rs b/tests/run/empty_main.rs index b21b5a20759..1c82ba86112 100644 --- a/tests/run/empty_main.rs +++ b/tests/run/empty_main.rs @@ -9,12 +9,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{Sized, Copy, Receiver, Freeze}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/exit.rs b/tests/run/exit.rs index cb7158be029..aa95d648d5c 100644 --- a/tests/run/exit.rs +++ b/tests/run/exit.rs @@ -16,18 +16,7 @@ mod libc { } } -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/exit_code.rs b/tests/run/exit_code.rs index 477659da077..c1800cc0f07 100644 --- a/tests/run/exit_code.rs +++ b/tests/run/exit_code.rs @@ -9,18 +9,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/fun_ptr.rs b/tests/run/fun_ptr.rs index 92462bbacac..67908a7dc9b 100644 --- a/tests/run/fun_ptr.rs +++ b/tests/run/fun_ptr.rs @@ -10,21 +10,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Add, - Sub, - Index, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/mut_ref.rs b/tests/run/mut_ref.rs index afe09699799..94ae8407deb 100644 --- a/tests/run/mut_ref.rs +++ b/tests/run/mut_ref.rs @@ -13,19 +13,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Add, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/operations.rs b/tests/run/operations.rs index 4f21c14bee7..2974099948d 100644 --- a/tests/run/operations.rs +++ b/tests/run/operations.rs @@ -11,22 +11,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Add, - Sub, - Mul, - Deref, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/ptr_cast.rs b/tests/run/ptr_cast.rs index d3ed4d47103..310ae18537d 100644 --- a/tests/run/ptr_cast.rs +++ b/tests/run/ptr_cast.rs @@ -10,22 +10,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Add, - Sub, - Index, - Sized, - Copy, - Receiver, - Freeze -}; - +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/return-tuple.rs b/tests/run/return-tuple.rs index a6591a74aec..6f19eb10e49 100644 --- a/tests/run/return-tuple.rs +++ b/tests/run/return-tuple.rs @@ -12,18 +12,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/slice.rs b/tests/run/slice.rs index 34bcb2cb444..b91d4cb013f 100644 --- a/tests/run/slice.rs +++ b/tests/run/slice.rs @@ -10,21 +10,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Index, - Sized, - Copy, - Receiver, - Freeze, - Unsize, - CoerceUnsized -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/static.rs b/tests/run/static.rs index e662d802b41..874a69fd863 100644 --- a/tests/run/static.rs +++ b/tests/run/static.rs @@ -15,21 +15,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Sized, - Copy, - Receiver, - Freeze, - Destruct, - Drop, - StructuralPartialEq -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/structs.rs b/tests/run/structs.rs index b413b3e951f..d0edc3b7fd0 100644 --- a/tests/run/structs.rs +++ b/tests/run/structs.rs @@ -11,18 +11,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code diff --git a/tests/run/tuple.rs b/tests/run/tuple.rs index 875983fabda..8520cae436d 100644 --- a/tests/run/tuple.rs +++ b/tests/run/tuple.rs @@ -10,18 +10,7 @@ #![no_std] #![no_core] -/* - * Core - */ - -extern crate mini_core; -use mini_core::{ - libc, - Sized, - Copy, - Receiver, - Freeze -}; +include!("../../example/mini_core.rs"); /* * Code From 996eba438562872d7a73335a952ab96556423845 Mon Sep 17 00:00:00 2001 From: g4titanx Date: Fri, 3 Jan 2025 08:46:40 +0100 Subject: [PATCH 3/3] add include feature tag --- tests/run/abort1.rs | 2 +- tests/run/abort2.rs | 2 +- tests/run/array.rs | 2 +- tests/run/assign.rs | 2 +- tests/run/closure.rs | 2 +- tests/run/condition.rs | 2 +- tests/run/empty_main.rs | 2 +- tests/run/exit.rs | 2 +- tests/run/exit_code.rs | 2 +- tests/run/fun_ptr.rs | 2 +- tests/run/mut_ref.rs | 2 +- tests/run/operations.rs | 2 +- tests/run/ptr_cast.rs | 2 +- tests/run/return-tuple.rs | 2 +- tests/run/slice.rs | 2 +- tests/run/static.rs | 2 +- tests/run/structs.rs | 2 +- tests/run/tuple.rs | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/run/abort1.rs b/tests/run/abort1.rs index 5d2b6e4cc2f..1a64d2dabb6 100644 --- a/tests/run/abort1.rs +++ b/tests/run/abort1.rs @@ -3,7 +3,7 @@ // Run-time: // status: signal -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/abort2.rs b/tests/run/abort2.rs index d15319b765a..5036120c018 100644 --- a/tests/run/abort2.rs +++ b/tests/run/abort2.rs @@ -3,7 +3,7 @@ // Run-time: // status: signal -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/array.rs b/tests/run/array.rs index 78aa921767c..24089513d92 100644 --- a/tests/run/array.rs +++ b/tests/run/array.rs @@ -7,7 +7,7 @@ // 5 // 10 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/assign.rs b/tests/run/assign.rs index c86857660a7..e2996f91f5f 100644 --- a/tests/run/assign.rs +++ b/tests/run/assign.rs @@ -6,7 +6,7 @@ // 10 #![allow(internal_features, unused_attributes)] -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![no_std] #![no_core] diff --git a/tests/run/closure.rs b/tests/run/closure.rs index 7e70cadcdc3..e1b81b3062b 100644 --- a/tests/run/closure.rs +++ b/tests/run/closure.rs @@ -8,7 +8,7 @@ // Int argument: 2 // Both args: 11 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/condition.rs b/tests/run/condition.rs index 16df95c3dc2..48ff1c6eb40 100644 --- a/tests/run/condition.rs +++ b/tests/run/condition.rs @@ -5,7 +5,7 @@ // stdout: true // 1 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/empty_main.rs b/tests/run/empty_main.rs index 1c82ba86112..244ced6d19f 100644 --- a/tests/run/empty_main.rs +++ b/tests/run/empty_main.rs @@ -3,7 +3,7 @@ // Run-time: // status: 0 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/exit.rs b/tests/run/exit.rs index aa95d648d5c..ec7d630cdee 100644 --- a/tests/run/exit.rs +++ b/tests/run/exit.rs @@ -3,7 +3,7 @@ // Run-time: // status: 2 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/exit_code.rs b/tests/run/exit_code.rs index c1800cc0f07..8940409ca7c 100644 --- a/tests/run/exit_code.rs +++ b/tests/run/exit_code.rs @@ -3,7 +3,7 @@ // Run-time: // status: 1 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/fun_ptr.rs b/tests/run/fun_ptr.rs index 67908a7dc9b..90e6b6fb646 100644 --- a/tests/run/fun_ptr.rs +++ b/tests/run/fun_ptr.rs @@ -4,7 +4,7 @@ // status: 0 // stdout: 1 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/mut_ref.rs b/tests/run/mut_ref.rs index 94ae8407deb..94ff7f7f74b 100644 --- a/tests/run/mut_ref.rs +++ b/tests/run/mut_ref.rs @@ -8,7 +8,7 @@ // 11 #![allow(internal_features, unused_attributes)] -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![no_std] #![no_core] diff --git a/tests/run/operations.rs b/tests/run/operations.rs index 2974099948d..500587bbc6f 100644 --- a/tests/run/operations.rs +++ b/tests/run/operations.rs @@ -6,7 +6,7 @@ // 10 #![allow(internal_features, unused_attributes)] -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![no_std] #![no_core] diff --git a/tests/run/ptr_cast.rs b/tests/run/ptr_cast.rs index 310ae18537d..bde51efa8c1 100644 --- a/tests/run/ptr_cast.rs +++ b/tests/run/ptr_cast.rs @@ -4,7 +4,7 @@ // status: 0 // stdout: 1 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/return-tuple.rs b/tests/run/return-tuple.rs index 6f19eb10e49..8c6c3bc8c99 100644 --- a/tests/run/return-tuple.rs +++ b/tests/run/return-tuple.rs @@ -6,7 +6,7 @@ // 10 // 42 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/slice.rs b/tests/run/slice.rs index b91d4cb013f..1b20f0a1da6 100644 --- a/tests/run/slice.rs +++ b/tests/run/slice.rs @@ -4,7 +4,7 @@ // status: 0 // stdout: 5 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/static.rs b/tests/run/static.rs index 874a69fd863..7c7c1f6281d 100644 --- a/tests/run/static.rs +++ b/tests/run/static.rs @@ -9,7 +9,7 @@ // 12 // 1 -#![feature(no_core, start)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/structs.rs b/tests/run/structs.rs index d0edc3b7fd0..fa8fd41e2f6 100644 --- a/tests/run/structs.rs +++ b/tests/run/structs.rs @@ -5,7 +5,7 @@ // stdout: 1 // 2 -#![feature(auto_traits, lang_items, no_core, start, intrinsics)] +#![feature(no_core, start, include, include_str)] #![allow(internal_features)] #![no_std] diff --git a/tests/run/tuple.rs b/tests/run/tuple.rs index 8520cae436d..c9e86584396 100644 --- a/tests/run/tuple.rs +++ b/tests/run/tuple.rs @@ -4,7 +4,7 @@ // status: 0 // stdout: 3 -#![feature(auto_traits, lang_items, no_core, start, intrinsics)] +#![feature(no_core, start, include, include_strs)] #![allow(internal_features)] #![no_std]