Skip to content

Commit 499de70

Browse files
authored
Merge pull request #639 from madhav-madhusoodanan/test_update_mini_core
Cleaned up tests by bringing objects under `mini_core` into scope
2 parents fcac229 + 572da5c commit 499de70

21 files changed

+124
-968
lines changed

example/mini_core.rs

+57-52
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ impl<T: ?Sized> LegacyReceiver for &T {}
5151
impl<T: ?Sized> LegacyReceiver for &mut T {}
5252
impl<T: ?Sized, A: Allocator> LegacyReceiver for Box<T, A> {}
5353

54+
#[lang = "receiver"]
55+
trait Receiver {
56+
}
57+
5458
#[lang = "copy"]
5559
pub trait Copy {}
5660

@@ -139,6 +143,14 @@ impl Mul for usize {
139143
}
140144
}
141145

146+
impl Mul for isize {
147+
type Output = Self;
148+
149+
fn mul(self, rhs: Self) -> Self::Output {
150+
self * rhs
151+
}
152+
}
153+
142154
#[lang = "add"]
143155
pub trait Add<RHS = Self> {
144156
type Output;
@@ -162,6 +174,14 @@ impl Add for i8 {
162174
}
163175
}
164176

177+
impl Add for i32 {
178+
type Output = Self;
179+
180+
fn add(self, rhs: Self) -> Self {
181+
self + rhs
182+
}
183+
}
184+
165185
impl Add for usize {
166186
type Output = Self;
167187

@@ -193,6 +213,14 @@ impl Sub for usize {
193213
}
194214
}
195215

216+
impl Sub for isize {
217+
type Output = Self;
218+
219+
fn sub(self, rhs: Self) -> Self {
220+
self - rhs
221+
}
222+
}
223+
196224
impl Sub for u8 {
197225
type Output = Self;
198226

@@ -588,70 +616,43 @@ pub union MaybeUninit<T> {
588616

589617
pub mod intrinsics {
590618
#[rustc_intrinsic]
591-
#[rustc_intrinsic_must_be_overridden]
592-
pub fn abort() -> ! {
593-
loop {}
594-
}
619+
pub fn abort() -> !;
620+
595621
#[rustc_intrinsic]
596-
#[rustc_intrinsic_must_be_overridden]
597-
pub fn size_of<T>() -> usize {
598-
loop {}
599-
}
622+
pub fn size_of<T>() -> usize;
623+
600624
#[rustc_intrinsic]
601-
#[rustc_intrinsic_must_be_overridden]
602-
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize {
603-
loop {}
604-
}
625+
pub unsafe fn size_of_val<T: ?::Sized>(_val: *const T) -> usize;
626+
605627
#[rustc_intrinsic]
606-
#[rustc_intrinsic_must_be_overridden]
607-
pub fn min_align_of<T>() -> usize {
608-
loop {}
609-
}
628+
pub fn min_align_of<T>() -> usize;
629+
610630
#[rustc_intrinsic]
611-
#[rustc_intrinsic_must_be_overridden]
612-
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize {
613-
loop {}
614-
}
631+
pub unsafe fn min_align_of_val<T: ?::Sized>(_val: *const T) -> usize;
632+
615633
#[rustc_intrinsic]
616-
#[rustc_intrinsic_must_be_overridden]
617-
pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize) {
618-
loop {}
619-
}
634+
pub unsafe fn copy<T>(_src: *const T, _dst: *mut T, _count: usize);
635+
620636
#[rustc_intrinsic]
621-
#[rustc_intrinsic_must_be_overridden]
622-
pub unsafe fn transmute<T, U>(_e: T) -> U {
623-
loop {}
624-
}
637+
pub unsafe fn transmute<T, U>(_e: T) -> U;
638+
625639
#[rustc_intrinsic]
626-
#[rustc_intrinsic_must_be_overridden]
627-
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32 {
628-
loop {}
629-
}
640+
pub unsafe fn ctlz_nonzero<T>(_x: T) -> u32;
641+
630642
#[rustc_intrinsic]
631-
#[rustc_intrinsic_must_be_overridden]
632-
pub fn needs_drop<T: ?::Sized>() -> bool {
633-
loop {}
634-
}
643+
pub fn needs_drop<T: ?::Sized>() -> bool;
644+
635645
#[rustc_intrinsic]
636-
#[rustc_intrinsic_must_be_overridden]
637-
pub fn bitreverse<T>(_x: T) -> T {
638-
loop {}
639-
}
646+
pub fn bitreverse<T>(_x: T) -> T;
647+
640648
#[rustc_intrinsic]
641-
#[rustc_intrinsic_must_be_overridden]
642-
pub fn bswap<T>(_x: T) -> T {
643-
loop {}
644-
}
649+
pub fn bswap<T>(_x: T) -> T;
650+
645651
#[rustc_intrinsic]
646-
#[rustc_intrinsic_must_be_overridden]
647-
pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize) {
648-
loop {}
649-
}
652+
pub unsafe fn write_bytes<T>(_dst: *mut T, _val: u8, _count: usize);
653+
650654
#[rustc_intrinsic]
651-
#[rustc_intrinsic_must_be_overridden]
652-
pub unsafe fn unreachable() -> ! {
653-
loop {}
654-
}
655+
pub unsafe fn unreachable() -> !;
655656
}
656657

657658
pub mod libc {
@@ -664,6 +665,10 @@ pub mod libc {
664665
pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
665666
pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
666667
pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
668+
pub fn fflush(stream: *mut i32) -> i32;
669+
pub fn exit(status: i32);
670+
671+
pub static stdout: *mut i32;
667672
}
668673
}
669674

tests/run/abort1.rs

+3-38
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,12 @@
33
// Run-time:
44
// status: signal
55

6-
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
7-
#![allow(internal_features)]
8-
6+
#![feature(no_core, start)]
97
#![no_std]
108
#![no_core]
119

12-
/*
13-
* Core
14-
*/
15-
16-
// Because we don't have core yet.
17-
#[lang = "sized"]
18-
pub trait Sized {}
19-
20-
#[lang = "copy"]
21-
trait Copy {
22-
}
23-
24-
impl Copy for isize {}
25-
26-
#[lang = "receiver"]
27-
trait Receiver {
28-
}
29-
30-
#[lang = "freeze"]
31-
pub(crate) unsafe auto trait Freeze {}
32-
33-
mod intrinsics {
34-
use super::Sized;
35-
36-
#[rustc_nounwind]
37-
#[rustc_intrinsic]
38-
#[rustc_intrinsic_must_be_overridden]
39-
pub fn abort() -> ! {
40-
loop {}
41-
}
42-
}
43-
44-
/*
45-
* Code
46-
*/
10+
extern crate mini_core;
11+
use mini_core::*;
4712

4813
fn test_fail() -> ! {
4914
unsafe { intrinsics::abort() };

tests/run/abort2.rs

+3-38
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,12 @@
33
// Run-time:
44
// status: signal
55

6-
#![feature(auto_traits, lang_items, no_core, start, intrinsics, rustc_attrs)]
7-
#![allow(internal_features)]
8-
6+
#![feature(no_core, start)]
97
#![no_std]
108
#![no_core]
119

12-
/*
13-
* Core
14-
*/
15-
16-
// Because we don't have core yet.
17-
#[lang = "sized"]
18-
pub trait Sized {}
19-
20-
#[lang = "copy"]
21-
trait Copy {
22-
}
23-
24-
impl Copy for isize {}
25-
26-
#[lang = "receiver"]
27-
trait Receiver {
28-
}
29-
30-
#[lang = "freeze"]
31-
pub(crate) unsafe auto trait Freeze {}
32-
33-
mod intrinsics {
34-
use super::Sized;
35-
36-
#[rustc_nounwind]
37-
#[rustc_intrinsic]
38-
#[rustc_intrinsic_must_be_overridden]
39-
pub fn abort() -> ! {
40-
loop {}
41-
}
42-
}
43-
44-
/*
45-
* Code
46-
*/
10+
extern crate mini_core;
11+
use mini_core::*;
4712

4813
fn fail() -> i32 {
4914
unsafe { intrinsics::abort() };

tests/run/array.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,11 @@
88
// 10
99

1010
#![feature(no_core, start)]
11-
1211
#![no_std]
1312
#![no_core]
1413

1514
extern crate mini_core;
16-
17-
mod libc {
18-
#[link(name = "c")]
19-
extern "C" {
20-
pub fn printf(format: *const i8, ...) -> i32;
21-
pub fn puts(s: *const u8) -> i32;
22-
}
23-
}
15+
use mini_core::*;
2416

2517
static mut ONE: usize = 1;
2618

0 commit comments

Comments
 (0)