-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
no_std.rs
47 lines (35 loc) · 1.34 KB
/
no_std.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// This example depends on the no_std_examples feature being enabled on the crate;
// without it, we have to go and chop everything off so that it can compile.
// If you are basing something off this example, please note that all the `feature =
// "no_std_examples"`
// cfg-gating is a workaround for Cargo until https://github.com/rust-lang/cargo/issues/1570 lands.
// Do not include it if you copy any code.
#![cfg_attr(feature = "no_std_examples", feature(lang_items, start, alloc))]
#![cfg_attr(feature = "no_std_examples", no_std)]
#[cfg(not(feature = "no_std_examples"))]
fn main() { }
#[cfg(feature = "no_std_examples")]
#[macro_use]
extern crate mopa;
#[cfg(feature = "no_std_examples")]
extern crate alloc;
#[cfg(feature = "no_std_examples")]
mod silly_wrapper_to_save_writing_the_whole_cfg_incantation_on_every_item {
use alloc::boxed::Box;
trait Panic { fn panic(&self) { } }
trait PanicAny: Panic + ::mopa::Any { }
mopafy!(PanicAny);
impl Panic for i32 { }
impl<T: Panic + ::mopa::Any + 'static> PanicAny for T { }
#[start]
fn start(_argc: isize, _argv: *const *const u8) -> isize {
let p: &PanicAny = &2;
if p.is::<i32>() {
0
} else {
1
}
}
#[lang = "eh_personality"] extern fn eh_personality() {}
#[lang = "panic_fmt"] extern fn panic_fmt() {}
}