2018-06-17 11:05:11 -05: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 08:23:40 -05:00
|
|
|
impl Mul for u8 {
|
|
|
|
type Output = Self;
|
2018-06-17 11:05:11 -05:00
|
|
|
|
2018-06-27 08:23:40 -05:00
|
|
|
fn mul(self, rhs: Self) -> Self {
|
2018-06-17 11:05:11 -05:00
|
|
|
self * rhs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[lang="panic"]
|
|
|
|
fn panic(_expr_file_line_col: &(&'static str, &'static str, u32, u32)) -> ! {
|
|
|
|
loop {}
|
|
|
|
}
|
|
|
|
|
2018-06-23 11:26:54 -05: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 08:23:40 -05:00
|
|
|
fn abc(a: u8) -> u8 {
|
2018-06-17 11:05:11 -05:00
|
|
|
a * 2
|
|
|
|
}
|
|
|
|
|
2018-06-27 08:23:40 -05:00
|
|
|
fn bcd(b: bool, a: u8) -> u8 {
|
2018-06-17 11:05:11 -05:00
|
|
|
if b {
|
|
|
|
a * 2
|
|
|
|
} else {
|
|
|
|
a * 3
|
|
|
|
}
|
2018-06-20 08:15:28 -05:00
|
|
|
}
|
2018-06-17 12:10:00 -05:00
|
|
|
|
2018-06-23 11:26:54 -05:00
|
|
|
// FIXME make calls work
|
|
|
|
/*fn call() {
|
2018-06-17 12:10:00 -05:00
|
|
|
abc(42);
|
|
|
|
}
|
2018-06-18 11:39:07 -05:00
|
|
|
|
|
|
|
fn indirect_call() {
|
|
|
|
let f: fn() = call;
|
|
|
|
f();
|
2018-06-23 11:26:54 -05: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 08:23:40 -05:00
|
|
|
fn ret_42() -> u8 {
|
2018-06-23 11:26:54 -05:00
|
|
|
42
|
2018-06-18 11:39:07 -05:00
|
|
|
}
|
2018-07-14 09:39:49 -05:00
|
|
|
|
|
|
|
fn return_str() -> &'static str {
|
|
|
|
"hello world"
|
|
|
|
}
|
|
|
|
|
|
|
|
fn promoted_val() -> &'static u8 {
|
|
|
|
&(1 * 2)
|
|
|
|
}
|