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