2018-06-17 18:05:11 +02:00
|
|
|
#![feature(no_core, lang_items)]
|
|
|
|
#![no_core]
|
|
|
|
|
|
|
|
#[lang="sized"]
|
|
|
|
trait Sized {}
|
|
|
|
|
|
|
|
#[lang="copy"]
|
|
|
|
trait Copy {}
|
|
|
|
|
|
|
|
#[lang="freeze"]
|
|
|
|
trait Freeze {}
|
|
|
|
|
|
|
|
#[lang="mul"]
|
|
|
|
trait Mul<RHS = Self> {
|
|
|
|
type Output;
|
|
|
|
|
|
|
|
#[must_use]
|
|
|
|
fn mul(self, rhs: RHS) -> Self::Output;
|
|
|
|
}
|
|
|
|
|
2018-06-27 15:23:40 +02:00
|
|
|
impl Mul for u8 {
|
|
|
|
type Output = Self;
|
2018-06-17 18:05:11 +02:00
|
|
|
|
2018-06-27 15:23:40 +02:00
|
|
|
fn mul(self, rhs: Self) -> Self {
|
2018-06-17 18:05:11 +02:00
|
|
|
self * rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang="panic"]
|
|
|
|
fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2018-06-23 18:26:54 +02:00
|
|
|
#[lang = "drop_in_place"]
|
|
|
|
#[allow(unconditional_recursion)]
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2018-06-27 15:23:40 +02:00
|
|
|
fn abc(a: u8) -> u8 {
|
2018-06-17 18:05:11 +02:00
|
|
|
a * 2
|
|
|
|
}
|
|
|
|
|
2018-06-27 15:23:40 +02:00
|
|
|
fn bcd(b: bool, a: u8) -> u8 {
|
2018-06-17 18:05:11 +02:00
|
|
|
if b {
|
|
|
|
a * 2
|
|
|
|
} else {
|
|
|
|
a * 3
|
|
|
|
}
|
2018-06-20 15:15:28 +02:00
|
|
|
}
|
2018-06-17 19:10:00 +02:00
|
|
|
|
2018-06-23 18:26:54 +02:00
|
|
|
// FIXME make calls work
|
|
|
|
/*fn call() {
|
2018-06-17 19:10:00 +02:00
|
|
|
abc(42);
|
|
|
|
}
|
2018-06-18 18:39:07 +02:00
|
|
|
|
|
|
|
fn indirect_call() {
|
|
|
|
let f: fn() = call;
|
|
|
|
f();
|
2018-06-23 18:26:54 +02:00
|
|
|
}*/
|
|
|
|
|
|
|
|
enum BoolOption {
|
|
|
|
Some(bool),
|
|
|
|
None,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn option_unwrap_or(o: BoolOption, d: bool) -> bool {
|
|
|
|
match o {
|
|
|
|
BoolOption::Some(b) => b,
|
|
|
|
BoolOption::None => d,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-27 15:23:40 +02:00
|
|
|
fn ret_42() -> u8 {
|
2018-06-23 18:26:54 +02:00
|
|
|
42
|
2018-06-18 18:39:07 +02:00
|
|
|
}
|