1 // Copyright 2015 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.
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 #![feature(rustc_attrs)]
11 // aux-build:mir_external_refs.rs
14 extern crate mir_external_refs
as ext
;
17 #[derive(Debug, PartialEq, Eq)]
22 fn hey2(&self) -> u8 { 44 }
26 fn hoy(&self) -> u8 { 43 }
27 fn hoy2() -> u8 { 45 }
31 fn f(self, other
: U
) -> u64;
35 fn f(self, other
: u32) -> u64 { self as u64 + other as u64 }
39 fn f(self, other
: u64) -> u64 { self as u64 - other }
43 fn f(self, other
: u64) -> u64 { self * other }
47 fn f(self, other
: u32) -> u64 { self ^ other as u64 }
51 fn staticmeth(i
: I
, o
: O
) -> (I
, O
) { (i, o) }
54 impl<I
, O
> T
<I
, O
> for O {}
62 #[derive(PartialEq, Debug, Eq)]
69 const C2
: [u8; 5] = [42; 5];
70 const C3
: [u8; 3] = [42, 41, 40];
71 const C4
: fn(u8) -> S
= S
;
77 fn parametric
<T
>(u
: T
) -> T
{
87 fn t2() -> fn(u8)->E
{
92 fn t3() -> fn(u8)->S
{
102 fn t5() -> fn(&S
)-> u8 {
113 fn t7() -> fn(u8)->ext
::E
{
118 fn t8() -> fn(u8)->ext
::S
{
123 fn t9() -> fn()->u8 {
128 fn t10() -> fn(&ext
::S
)->u8 {
129 <ext
::S
as ext
::X
>::hoy
133 fn t11() -> fn(u8)->u8 {
143 fn t13() -> [u8; 5] {
148 fn t13_2() -> [u8; 3] {
153 fn t14() -> fn()-> u8 {
158 fn t15() -> fn(&S
)-> u8 {
163 fn t16() -> fn(u32, u32)->u64 {
168 fn t17() -> fn(u32, u64)->u64 {
173 fn t18() -> fn(u64, u64)->u64 {
178 fn t19() -> fn(u64, u32)->u64 {
183 fn t20() -> fn(u64, u32)->(u64, u32) {
184 <u32 as T
<_
, _
>>::staticmeth
193 fn t22() -> Option
<u8> {
198 fn t23() -> (CEnum
, CEnum
) {
203 fn t24() -> fn(u8) -> S
{
208 assert_eq
!(t1()(), regular());
210 assert_eq
!(t2() as *mut (), E
::U
as *mut ());
211 assert_eq
!(t3() as *mut (), S
as *mut ());
213 assert_eq
!(t4()(), S
::hey());
215 assert_eq
!(t5()(&s
), <S
as X
>::hoy(&s
));
218 assert_eq
!(t6()(), ext
::regular_fn());
219 assert_eq
!(t7() as *mut (), ext
::E
::U
as *mut ());
220 assert_eq
!(t8() as *mut (), ext
::S
as *mut ());
222 assert_eq
!(t9()(), ext
::S
::hey());
223 let sext
= ext
::S(6);
224 assert_eq
!(t10()(&sext
), <ext
::S
as ext
::X
>::hoy(&sext
));
226 let p
= parametric
::<u8>;
227 assert_eq
!(t11() as *mut (), p
as *mut ());
229 assert_eq
!(t12(), C
);
230 assert_eq
!(t13(), C2
);
231 assert_eq
!(t13_2(), C3
);
233 assert_eq
!(t14()(), <S
as X
>::hoy2());
234 assert_eq
!(t15()(&s
), S
::hey2(&s
));
235 assert_eq
!(t16()(10u32, 20u32), F
::f(10u32, 20u32));
236 assert_eq
!(t17()(30u32, 10u64), F
::f(30u32, 10u64));
237 assert_eq
!(t18()(50u64, 5u64), F
::f(50u64, 5u64));
238 assert_eq
!(t19()(322u64, 2u32), F
::f(322u64, 2u32));
239 assert_eq
!(t20()(123u64, 38u32), <u32 as T
<_
, _
>>::staticmeth(123, 38));
240 assert_eq
!(t21(), Unit
);
241 assert_eq
!(t22(), None
);
242 assert_eq
!(t23(), (CEnum
::A
, CEnum
::B
));
243 assert_eq
!(t24(), C4
);