Improve mini_core_hello_world.rs

This commit is contained in:
bjorn3 2018-08-11 14:52:00 +02:00
parent af69258971
commit 9a8c25ae75
2 changed files with 10 additions and 4 deletions

View File

@ -140,6 +140,11 @@ pub fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> !
loop {}
}
#[lang = "eh_personality"]
fn eh_personality() -> ! {
loop {}
}
#[lang = "drop_in_place"]
#[allow(unconditional_recursion)]
pub unsafe fn drop_in_place<T: ?Sized>(to_drop: *mut T) {

View File

@ -1,7 +1,8 @@
// Adapted from https://github.com/sunfishcode/mir2cranelift/blob/master/rust-examples/nocore-hello-world.rs
#![feature(no_core, unboxed_closures, start)]
#![feature(no_core, unboxed_closures, start, lang_items)]
#![no_core]
#![no_main]
#![allow(dead_code)]
extern crate mini_core;
@ -15,11 +16,11 @@ extern "C" {
fn puts(s: *const u8);
}
#[start]
fn main(i: isize, _: *const *const u8) -> isize {
#[lang = "start"]
fn start(_main: *const u8, i: isize, _: *const *const u8) -> isize {
unsafe {
let (ptr, _): (*const u8, usize) = intrinsics::transmute("Hello!\0");
puts(ptr);
}
0
42
}