]> git.proxmox.com Git - rustc.git/blob - src/test/auxiliary/lang-item-public.rs
Imported Upstream version 1.0.0~beta
[rustc.git] / src / test / auxiliary / lang-item-public.rs
1 // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 #![feature(no_std)]
12 #![no_std]
13 #![feature(lang_items)]
14
15 #[lang="phantom_fn"]
16 pub trait PhantomFn<A:?Sized,R:?Sized=()> { }
17 impl<A:?Sized, R:?Sized, U:?Sized> PhantomFn<A,R> for U { }
18
19 #[lang="sized"]
20 pub trait Sized : PhantomFn<Self> {}
21
22 #[lang="panic"]
23 fn panic(_: &(&'static str, &'static str, usize)) -> ! { loop {} }
24
25 #[lang = "stack_exhausted"]
26 extern fn stack_exhausted() {}
27
28 #[lang = "eh_personality"]
29 extern fn eh_personality() {}
30
31 #[lang="copy"]
32 pub trait Copy : PhantomFn<Self> {
33 // Empty.
34 }
35
36 #[lang="rem"]
37 pub trait Rem<RHS=Self> {
38 type Output = Self;
39 fn rem(self, rhs: RHS) -> Self::Output;
40 }
41
42 impl Rem for isize {
43 type Output = isize;
44
45 #[inline]
46 fn rem(self, other: isize) -> isize {
47 // if you use `self % other` here, as one would expect, you
48 // get back an error because of potential failure/overflow,
49 // which tries to invoke error fns that don't have the
50 // appropriate signatures anymore. So...just return 0.
51 0
52 }
53 }