Skip to content

Commit b425573

Browse files
committed
Fix tests
1 parent db36370 commit b425573

File tree

14 files changed

+53
-771
lines changed

14 files changed

+53
-771
lines changed

example/mini_core.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,14 @@ impl Mul for usize {
142142
}
143143
}
144144

145+
impl Mul for i32 {
146+
type Output = Self;
147+
148+
fn mul(self, rhs: Self) -> Self::Output {
149+
self * rhs
150+
}
151+
}
152+
145153
#[lang = "add"]
146154
pub trait Add<RHS = Self> {
147155
type Output;
@@ -165,6 +173,14 @@ impl Add for i8 {
165173
}
166174
}
167175

176+
impl Add for i32 {
177+
type Output = Self;
178+
179+
fn add(self, rhs: Self) -> Self {
180+
self + rhs
181+
}
182+
}
183+
168184
impl Add for usize {
169185
type Output = Self;
170186

@@ -212,6 +228,14 @@ impl Sub for i8 {
212228
}
213229
}
214230

231+
impl Sub for i32 {
232+
type Output = Self;
233+
234+
fn sub(self, rhs: Self) -> Self {
235+
self - rhs
236+
}
237+
}
238+
215239
impl Sub for i16 {
216240
type Output = Self;
217241

@@ -667,6 +691,7 @@ pub mod libc {
667691
pub fn memcpy(dst: *mut u8, src: *const u8, size: usize);
668692
pub fn memmove(dst: *mut u8, src: *const u8, size: usize);
669693
pub fn strncpy(dst: *mut u8, src: *const u8, size: usize);
694+
pub fn exit(status: i32);
670695
}
671696
}
672697

tests/run/abort1.rs

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,13 @@
1010
#![no_core]
1111
#![no_main]
1212

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

4915
fn test_fail() -> ! {
50-
unsafe { intrinsics::abort() };
16+
mini_core::intrinsics::abort();
5117
}
5218

5319
#[no_mangle]
54-
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
20+
extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 {
5521
test_fail();
5622
}

tests/run/abort2.rs

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,10 @@
1010
#![no_core]
1111
#![no_main]
1212

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

4915
fn fail() -> i32 {
50-
unsafe { intrinsics::abort() };
16+
mini_core::intrinsics::abort();
5117
0
5218
}
5319

tests/run/assign.rs

Lines changed: 4 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -6,132 +6,15 @@
66
// 10
77

88
#![allow(internal_features, unused_attributes)]
9-
#![feature(auto_traits, lang_items, no_core, intrinsics, rustc_attrs, track_caller)]
9+
#![feature(auto_traits, lang_items, no_core, intrinsics, rustc_attrs)]
1010

1111
#![no_std]
1212
#![no_core]
1313
#![no_main]
1414

15-
/*
16-
* Core
17-
*/
15+
extern crate mini_core;
1816

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

13619
fn inc_ref(num: &mut isize) -> isize {
13720
*num = *num + 5;
@@ -144,7 +27,7 @@ fn inc(num: isize) -> isize {
14427

14528

14629
#[no_mangle]
147-
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
30+
extern "C" fn main(mut argc: isize, _argv: *const *const u8) -> i32 {
14831
argc = inc(argc);
14932
unsafe {
15033
libc::printf(b"%ld\n\0" as *const u8 as *const i8, argc);

tests/run/closure.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ mod libc {
2424
}
2525

2626
#[no_mangle]
27-
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {
27+
extern "C" fn main(argc: isize, _argv: *const *const u8) -> i32 {
2828
let string = "Arg: %d\n\0";
2929
let mut closure = || {
3030
unsafe {

tests/run/empty_main.rs

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,7 @@
1010
#![no_core]
1111
#![no_main]
1212

13-
/*
14-
* Core
15-
*/
16-
17-
// Because we don't have core yet.
18-
#[lang = "sized"]
19-
pub trait Sized {}
20-
21-
#[lang = "copy"]
22-
trait Copy {
23-
}
24-
25-
impl Copy for isize {}
26-
27-
#[lang = "receiver"]
28-
trait Receiver {
29-
}
30-
31-
#[lang = "freeze"]
32-
pub(crate) unsafe auto trait Freeze {}
33-
34-
/*
35-
* Code
36-
*/
13+
extern crate mini_core;
3714

3815
#[no_mangle]
3916
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {

tests/run/exit.rs

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,9 @@
1010
#![no_core]
1111
#![no_main]
1212

13-
mod libc {
14-
#[link(name = "c")]
15-
extern "C" {
16-
pub fn exit(status: i32);
17-
}
18-
}
19-
20-
/*
21-
* Core
22-
*/
23-
24-
// Because we don't have core yet.
25-
#[lang = "sized"]
26-
pub trait Sized {}
27-
28-
#[lang = "copy"]
29-
trait Copy {
30-
}
31-
32-
impl Copy for isize {}
33-
34-
#[lang = "receiver"]
35-
trait Receiver {
36-
}
37-
38-
#[lang = "freeze"]
39-
pub(crate) unsafe auto trait Freeze {}
13+
extern crate mini_core;
4014

41-
/*
42-
* Code
43-
*/
15+
use mini_core::libc;
4416

4517
#[no_mangle]
4618
extern "C" fn main(argc: i32, _argv: *const *const u8) -> i32 {

0 commit comments

Comments
 (0)