Skip to content

Commit 8db8c7b

Browse files
cleaned up tests by bringing objects under mini_core into scope
1 parent fcac229 commit 8db8c7b

File tree

18 files changed

+85
-780
lines changed

18 files changed

+85
-780
lines changed

example/mini_core.rs

Lines changed: 56 additions & 52 deletions
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,9 @@ 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+
670+
pub static stdout: *mut i32;
667671
}
668672
}
669673

tests/run/abort1.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,8 @@
99
#![no_std]
1010
#![no_core]
1111

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-
}
12+
extern crate mini_core;
13+
use minicore::*;
4314

4415
/*
4516
* Code

tests/run/abort2.rs

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -9,37 +9,8 @@
99
#![no_std]
1010
#![no_core]
1111

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-
}
12+
extern crate mini_core;
13+
use minicore::*;
4314

4415
/*
4516
* Code

tests/run/assign.rs

Lines changed: 2 additions & 110 deletions
Original file line numberDiff line numberDiff line change
@@ -11,116 +11,8 @@
1111
#![no_std]
1212
#![no_core]
1313

14-
/*
15-
* Core
16-
*/
17-
18-
// Because we don't have core yet.
19-
#[lang = "sized"]
20-
pub trait Sized {}
21-
22-
#[lang = "copy"]
23-
trait Copy {
24-
}
25-
26-
impl Copy for isize {}
27-
impl Copy for *mut i32 {}
28-
impl Copy for usize {}
29-
impl Copy for u8 {}
30-
impl Copy for i8 {}
31-
impl Copy for i32 {}
32-
33-
#[lang = "receiver"]
34-
trait Receiver {
35-
}
36-
37-
#[lang = "freeze"]
38-
pub(crate) unsafe auto trait Freeze {}
39-
40-
#[lang = "panic_location"]
41-
struct PanicLocation {
42-
file: &'static str,
43-
line: u32,
44-
column: u32,
45-
}
46-
47-
mod libc {
48-
#[link(name = "c")]
49-
extern "C" {
50-
pub fn puts(s: *const u8) -> i32;
51-
pub fn fflush(stream: *mut i32) -> i32;
52-
pub fn printf(format: *const i8, ...) -> i32;
53-
54-
pub static stdout: *mut i32;
55-
}
56-
}
57-
58-
mod intrinsics {
59-
#[rustc_nounwind]
60-
#[rustc_intrinsic]
61-
#[rustc_intrinsic_must_be_overridden]
62-
pub fn abort() -> ! {
63-
loop {}
64-
}
65-
}
66-
67-
#[lang = "panic"]
68-
#[track_caller]
69-
#[no_mangle]
70-
pub fn panic(_msg: &'static str) -> ! {
71-
unsafe {
72-
libc::puts("Panicking\0" as *const str as *const u8);
73-
libc::fflush(libc::stdout);
74-
intrinsics::abort();
75-
}
76-
}
77-
78-
#[lang = "add"]
79-
trait Add<RHS = Self> {
80-
type Output;
81-
82-
fn add(self, rhs: RHS) -> Self::Output;
83-
}
84-
85-
impl Add for u8 {
86-
type Output = Self;
87-
88-
fn add(self, rhs: Self) -> Self {
89-
self + rhs
90-
}
91-
}
92-
93-
impl Add for i8 {
94-
type Output = Self;
95-
96-
fn add(self, rhs: Self) -> Self {
97-
self + rhs
98-
}
99-
}
100-
101-
impl Add for i32 {
102-
type Output = Self;
103-
104-
fn add(self, rhs: Self) -> Self {
105-
self + rhs
106-
}
107-
}
108-
109-
impl Add for usize {
110-
type Output = Self;
111-
112-
fn add(self, rhs: Self) -> Self {
113-
self + rhs
114-
}
115-
}
116-
117-
impl Add for isize {
118-
type Output = Self;
119-
120-
fn add(self, rhs: Self) -> Self {
121-
self + rhs
122-
}
123-
}
14+
extern crate mini_core;
15+
use minicore::*;
12416

12517
#[track_caller]
12618
#[lang = "panic_const_add_overflow"]

tests/run/closure.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,7 @@
1414
#![no_core]
1515

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

2519
#[start]
2620
fn main(mut argc: isize, _argv: *const *const u8) -> isize {

tests/run/condition.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,7 @@
1111
#![no_core]
1212

1313
extern crate mini_core;
14-
15-
mod libc {
16-
#[link(name = "c")]
17-
extern "C" {
18-
pub fn printf(format: *const i8, ...) -> i32;
19-
}
20-
}
14+
use minicore::*;
2115

2216
#[start]
2317
fn main(argc: isize, _argv: *const *const u8) -> isize {

0 commit comments

Comments
 (0)