Merge pull request #639 from madhav-madhusoodanan/test_update_mini_core

Cleaned up tests by bringing objects under `mini_core` into scope
This commit is contained in:
antoyo 2025-03-08 07:52:21 -05:00 committed by GitHub
commit 499de70f3a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
21 changed files with 124 additions and 968 deletions

View file

@ -51,6 +51,10 @@ impl<T: ?Sized> LegacyReceiver for &T {}
impl<T: ?Sized> LegacyReceiver for &mut T {} impl<T: ?Sized> LegacyReceiver for &mut T {}
impl<T: ?Sized, A: Allocator> LegacyReceiver for Box<T, A> {} impl<T: ?Sized, A: Allocator> LegacyReceiver for Box<T, A> {}
#[lang = "receiver"]
trait Receiver {
}
#[lang = "copy"] #[lang = "copy"]
pub trait Copy {} pub trait Copy {}
@ -139,6 +143,14 @@ impl Mul for usize {
} }
} }
impl Mul for isize {
type Output = Self;
fn mul(self, rhs: Self) -> Self::Output {
self * rhs
}
}
#[lang = "add"] #[lang = "add"]
pub trait Add<RHS = Self> { pub trait Add<RHS = Self> {
type Output; type Output;
@ -162,6 +174,14 @@ impl Add for i8 {
} }
} }
impl Add for i32 {
type Output = Self;
fn add(self, rhs: Self) -> Self {
self + rhs
}
}
impl Add for usize { impl Add for usize {
type Output = Self; type Output = Self;
@ -193,6 +213,14 @@ impl Sub for usize {
} }
} }
impl Sub for isize {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
self - rhs
}
}
impl Sub for u8 { impl Sub for u8 {
type Output = Self; type Output = Self;
@ -588,70 +616,43 @@ pub union MaybeUninit<T> {
pub mod intrinsics { pub mod intrinsics {
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub fn abort() -> !;
pub fn abort() -> ! {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub fn size_of<T>() -> usize;
pub fn size_of<T>() -> usize {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize;
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub fn min_align_of<T>() -> usize;
pub fn min_align_of<T>() -> usize {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize;
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize);
pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize) {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub unsafe fn transmute<T, U>(_e: T) -> U;
pub unsafe fn transmute<T, U>(_e: T) -> U {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32;
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32 {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub fn needs_drop<T: ?::Sized>() -> bool;
pub fn needs_drop<T: ?::Sized>() -> bool {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub fn bitreverse<T>(_x: T) -> T;
pub fn bitreverse<T>(_x: T) -> T {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub fn bswap<T>(_x: T) -> T;
pub fn bswap<T>(_x: T) -> T {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize);
pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize) {
loop {}
}
#[rustc_intrinsic] #[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden] pub unsafe fn unreachable() -> !;
pub unsafe fn unreachable() -> ! {
loop {}
}
} }
pub mod libc { pub mod libc {
@ -664,6 +665,10 @@ pub mod libc {
pub fn memcpy(dst: *mut u8, src: *const u8, size: usize); pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
pub fn memmove(dst: *mut u8, src: *const u8, size: usize); pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
pub fn strncpy(dst: *mut u8, src: *const u8, size: usize); pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
pub fn fflush(stream: *mut i32) -> i32;
pub fn exit(status: i32);
pub static stdout: *mut i32;
} }
} }

View file

@ -3,47 +3,12 @@
// Run-time: // Run-time:
// status: signal // status: signal
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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;
#[rustc_nounwind]
#[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub fn abort() -> ! {
loop {}
}
}
/*
* Code
*/
fn test_fail() -> ! { fn test_fail() -> ! {
unsafe { intrinsics::abort() }; unsafe { intrinsics::abort() };

View file

@ -3,47 +3,12 @@
// Run-time: // Run-time:
// status: signal // status: signal
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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;
#[rustc_nounwind]
#[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub fn abort() -> ! {
loop {}
}
}
/*
* Code
*/
fn fail() -> i32 { fn fail() -> i32 {
unsafe { intrinsics::abort() }; unsafe { intrinsics::abort() };

View file

@ -8,19 +8,11 @@
// 10 // 10
#![feature(no_core, start)] #![feature(no_core, start)]
#![no_std] #![no_std]
#![no_core] #![no_core]
extern crate mini_core; extern crate mini_core;
use mini_core::*;
mod libc {
#[link(name = "c")]
extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
pub fn puts(s: *const u8) -> i32;
}
}
static mut ONE: usize = 1; static mut ONE: usize = 1;

View file

@ -5,132 +5,12 @@
// 7 8 // 7 8
// 10 // 10
#![allow(internal_features, unused_attributes)] #![feature(no_core, start)]
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs, track_caller)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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 {
#[rustc_nounwind]
#[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub fn abort() -> ! {
loop {}
}
}
#[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<RHS = Self> {
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
*/
fn inc_ref(num: &mut isize) -> isize { fn inc_ref(num: &mut isize) -> isize {
*num = *num + 5; *num = *num + 5;
@ -141,7 +21,6 @@ fn inc(num: isize) -> isize {
num + 1 num + 1
} }
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {
argc = inc(argc); argc = inc(argc);

View file

@ -9,54 +9,37 @@
// Both args: 11 // Both args: 11
#![feature(no_core, start)] #![feature(no_core, start)]
#![no_std] #![no_std]
#![no_core] #![no_core]
extern crate mini_core; extern crate mini_core;
use mini_core::*;
mod libc {
#[link(name = "c")]
extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
}
}
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {
let string = "Arg: %d\n\0"; let string = "Arg: %d\n\0";
let mut closure = || { let mut closure = || unsafe {
unsafe {
libc::printf(string as *const str as *const i8, argc); libc::printf(string as *const str as *const i8, argc);
}
}; };
closure(); closure();
let mut closure = || { let mut closure = || unsafe {
unsafe {
libc::printf("Argument: %d\n\0" as *const str as *const i8, argc); libc::printf("Argument: %d\n\0" as *const str as *const i8, argc);
}
}; };
closure(); closure();
let mut closure = |string| { let mut closure = |string| unsafe {
unsafe {
libc::printf(string as *const str as *const i8, argc); libc::printf(string as *const str as *const i8, argc);
}
}; };
closure("String arg: %d\n\0"); closure("String arg: %d\n\0");
let mut closure = |arg: isize| { let mut closure = |arg: isize| unsafe {
unsafe {
libc::printf("Int argument: %d\n\0" as *const str as *const i8, arg); libc::printf("Int argument: %d\n\0" as *const str as *const i8, arg);
}
}; };
closure(argc + 1); closure(argc + 1);
let mut closure = |string, arg: isize| { let mut closure = |string, arg: isize| unsafe {
unsafe {
libc::printf(string as *const str as *const i8, arg); libc::printf(string as *const str as *const i8, arg);
}
}; };
closure("Both args: %d\n\0", argc + 10); closure("Both args: %d\n\0", argc + 10);

View file

@ -6,18 +6,11 @@
// 1 // 1
#![feature(no_core, start)] #![feature(no_core, start)]
#![no_std] #![no_std]
#![no_core] #![no_core]
extern crate mini_core; extern crate mini_core;
use mini_core::*;
mod libc {
#[link(name = "c")]
extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
}
}
#[start] #[start]
fn main(argc: isize, _argv: *const *const u8) -> isize { fn main(argc: isize, _argv: *const *const u8) -> isize {
@ -26,8 +19,7 @@ fn main(argc: isize, _argv: *const *const u8) -> isize {
libc::printf(b"true\n\0" as *const u8 as *const i8); libc::printf(b"true\n\0" as *const u8 as *const i8);
} }
let string = let string = match argc {
match argc {
1 => b"1\n\0", 1 => b"1\n\0",
2 => b"2\n\0", 2 => b"2\n\0",
3 => b"3\n\0", 3 => b"3\n\0",

View file

@ -3,36 +3,12 @@
// Run-time: // Run-time:
// status: 0 // status: 0
#![feature(auto_traits, lang_items, no_core, start)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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 {}
/*
* Code
*/
#[start] #[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize { fn main(_argc: isize, _argv: *const *const u8) -> isize {

View file

@ -3,43 +3,12 @@
// Run-time: // Run-time:
// status: 2 // status: 2
#![feature(auto_traits, lang_items, no_core, start, intrinsics)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
mod libc { extern crate mini_core;
#[link(name = "c")] use mini_core::*;
extern "C" {
pub fn exit(status: i32);
}
}
/*
* 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 {}
/*
* Code
*/
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {

View file

@ -3,36 +3,12 @@
// Run-time: // Run-time:
// status: 1 // status: 1
#![feature(auto_traits, lang_items, no_core, start)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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 {}
/*
* Code
*/
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {

View file

@ -5,10 +5,6 @@
#![feature(const_black_box)] #![feature(const_black_box)]
/*
* Code
*/
fn main() { fn main() {
use std::hint::black_box; use std::hint::black_box;

View file

@ -5,18 +5,11 @@
// stdout: 1 // stdout: 1
#![feature(no_core, start)] #![feature(no_core, start)]
#![no_std] #![no_std]
#![no_core] #![no_core]
extern crate mini_core; extern crate mini_core;
use mini_core::*;
mod libc {
#[link(name = "c")]
extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
}
}
fn i16_as_i8(a: i16) -> i8 { fn i16_as_i8(a: i16) -> i8 {
a as i8 a as i8

View file

@ -5,10 +5,6 @@
#![feature(const_black_box)] #![feature(const_black_box)]
/*
* Code
*/
fn main() { fn main() {
use std::hint::black_box; use std::hint::black_box;

View file

@ -1,4 +1,3 @@
// Compiler: // Compiler:
// //
// Run-time: // Run-time:
@ -7,141 +6,19 @@
// 6 // 6
// 11 // 11
#![allow(internal_features, unused_attributes)] #![feature(no_core, start)]
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs, track_caller)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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 {
#[rustc_nounwind]
#[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub fn abort() -> ! {
loop {}
}
}
#[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<RHS = Self> {
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
*/
struct Test { struct Test {
field: isize, field: isize,
} }
fn test(num: isize) -> Test { fn test(num: isize) -> Test {
Test { Test { field: num + 1 }
field: num + 1,
}
} }
fn update_num(num: &mut isize) { fn update_num(num: &mut isize) {

View file

@ -5,231 +5,12 @@
// 39 // 39
// 10 // 10
#![allow(internal_features, unused_attributes)] #![feature(no_core, start)]
#![feature(auto_traits, lang_items, no_core, start, intrinsics, arbitrary_self_types, rustc_attrs)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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 = "legacy_receiver"]
trait LegacyReceiver {
}
#[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 {
#[rustc_nounwind]
#[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub fn abort() -> ! {
loop {}
}
}
#[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<RHS = Self> {
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<RHS = Self> {
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<RHS = Self> {
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");
}
/*
* Code
*/
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {

View file

@ -5,18 +5,11 @@
// stdout: 1 // stdout: 1
#![feature(no_core, start)] #![feature(no_core, start)]
#![no_std] #![no_std]
#![no_core] #![no_core]
extern crate mini_core; extern crate mini_core;
use mini_core::*;
mod libc {
#[link(name = "c")]
extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
}
}
static mut ONE: usize = 1; static mut ONE: usize = 1;

View file

@ -6,53 +6,12 @@
// 10 // 10
// 42 // 42
#![feature(auto_traits, lang_items, no_core, start, intrinsics)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
#[lang = "copy"] extern crate mini_core;
pub unsafe trait Copy {} use mini_core::*;
impl Copy for bool {}
impl Copy for u8 {}
impl Copy for u16 {}
impl Copy for u32 {}
impl Copy for u64 {}
impl Copy for usize {}
impl Copy for i8 {}
impl Copy for i16 {}
impl Copy for i32 {}
impl Copy for isize {}
impl Copy for f32 {}
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 = "legacy_receiver"]
trait LegacyReceiver {
}
#[lang = "freeze"]
pub(crate) unsafe auto trait Freeze {}
/*
* Code
*/
fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) { fn int_cast(a: u16, b: i16) -> (u8, u16, u32, usize, i8, i16, i32, isize, u8, u32) {
( (

View file

@ -5,25 +5,16 @@
// stdout: 5 // stdout: 5
#![feature(no_core, start)] #![feature(no_core, start)]
#![no_std] #![no_std]
#![no_core] #![no_core]
extern crate mini_core; extern crate mini_core;
use mini_core::*;
mod libc {
#[link(name = "c")]
extern "C" {
pub fn printf(format: *const i8, ...) -> i32;
}
}
static mut TWO: usize = 2; static mut TWO: usize = 2;
fn index_slice(s: &[u32]) -> u32 { fn index_slice(s: &[u32]) -> u32 {
unsafe { unsafe { s[TWO] }
s[TWO]
}
} }
#[start] #[start]

View file

@ -9,72 +9,12 @@
// 12 // 12
// 1 // 1
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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<T: ?Sized> Copy for *mut T {}
#[lang = "receiver"]
trait Receiver {
}
#[lang = "freeze"]
pub(crate) unsafe auto trait Freeze {}
mod intrinsics {
use super::Sized;
#[rustc_nounwind]
#[rustc_intrinsic]
#[rustc_intrinsic_must_be_overridden]
pub fn abort() -> ! {
loop {}
}
}
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<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);
}
/*
* Code
*/
struct Test { struct Test {
field: isize, field: isize,
@ -86,17 +26,11 @@ struct WithRef {
static mut CONSTANT: isize = 10; static mut CONSTANT: isize = 10;
static mut TEST: Test = Test { static mut TEST: Test = Test { field: 12 };
field: 12,
};
static mut TEST2: Test = Test { static mut TEST2: Test = Test { field: 14 };
field: 14,
};
static mut WITH_REF: WithRef = WithRef { static mut WITH_REF: WithRef = WithRef { refe: unsafe { &TEST } };
refe: unsafe { &TEST },
};
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {

View file

@ -5,43 +5,12 @@
// stdout: 1 // stdout: 1
// 2 // 2
#![feature(auto_traits, lang_items, no_core, start, intrinsics)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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;
}
}
/*
* Code
*/
struct Test { struct Test {
field: isize, field: isize,
@ -57,12 +26,8 @@ fn one() -> isize {
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {
let test = Test { let test = Test { field: one() };
field: one(), let two = Two { two: 2 };
};
let two = Two {
two: 2,
};
unsafe { unsafe {
libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field); libc::printf(b"%ld\n\0" as *const u8 as *const i8, test.field);
libc::printf(b"%ld\n\0" as *const u8 as *const i8, two.two); libc::printf(b"%ld\n\0" as *const u8 as *const i8, two.two);

View file

@ -4,43 +4,12 @@
// status: 0 // status: 0
// stdout: 3 // stdout: 3
#![feature(auto_traits, lang_items, no_core, start, intrinsics)] #![feature(no_core, start)]
#![allow(internal_features)]
#![no_std] #![no_std]
#![no_core] #![no_core]
/* extern crate mini_core;
* Core use mini_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;
}
}
/*
* Code
*/
#[start] #[start]
fn main(mut argc: isize, _argv: *const *const u8) -> isize { fn main(mut argc: isize, _argv: *const *const u8) -> isize {