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.
11 // aux-build:mir_external_refs.rs
13 extern crate mir_external_refs as ext;
16 #[derive(Debug, PartialEq, Eq)]
21 fn hey2(&self) -> u8 { 44 }
25 fn hoy(&self) -> u8 { 43 }
26 fn hoy2() -> u8 { 45 }
30 fn f(self, other: U) -> u64;
34 fn f(self, other: u32) -> u64 { self as u64 + other as u64 }
38 fn f(self, other: u64) -> u64 { self as u64 - other }
42 fn f(self, other: u64) -> u64 { self * other }
46 fn f(self, other: u32) -> u64 { self ^ other as u64 }
50 fn staticmeth(i: I, o: O) -> (I, O) { (i, o) }
53 impl<I, O> T<I, O> for O {}
61 #[derive(PartialEq, Debug, Eq)]
68 const C2: [u8; 5] = [42; 5];
69 const C3: [u8; 3] = [42, 41, 40];
70 const C4: fn(u8) -> S = S;
76 fn parametric<T>(u: T) -> T {
84 fn t2() -> fn(u8)->E {
88 fn t3() -> fn(u8)->S {
96 fn t5() -> fn(&S)-> u8 {
105 fn t7() -> fn(u8)->ext::E {
109 fn t8() -> fn(u8)->ext::S {
113 fn t9() -> fn()->u8 {
117 fn t10() -> fn(&ext::S)->u8 {
118 <ext::S as ext::X>::hoy
121 fn t11() -> fn(u8)->u8 {
129 fn t13() -> [u8; 5] {
133 fn t13_2() -> [u8; 3] {
137 fn t14() -> fn()-> u8 {
141 fn t15() -> fn(&S)-> u8 {
145 fn t16() -> fn(u32, u32)->u64 {
149 fn t17() -> fn(u32, u64)->u64 {
153 fn t18() -> fn(u64, u64)->u64 {
157 fn t19() -> fn(u64, u32)->u64 {
161 fn t20() -> fn(u64, u32)->(u64, u32) {
162 <u32 as T<_, _>>::staticmeth
169 fn t22() -> Option<u8> {
173 fn t23() -> (CEnum, CEnum) {
177 fn t24() -> fn(u8) -> S {
182 assert_eq!(t1()(), regular());
184 assert_eq!(t2() as *mut (), E::U as *mut ());
185 assert_eq!(t3() as *mut (), S as *mut ());
187 assert_eq!(t4()(), S::hey());
189 assert_eq!(t5()(&s), <S as X>::hoy(&s));
192 assert_eq!(t6()(), ext::regular_fn());
193 assert_eq!(t7() as *mut (), ext::E::U as *mut ());
194 assert_eq!(t8() as *mut (), ext::S as *mut ());
196 assert_eq!(t9()(), ext::S::hey());
197 let sext = ext::S(6);
198 assert_eq!(t10()(&sext), <ext::S as ext::X>::hoy(&sext));
200 let p = parametric::<u8>;
201 assert_eq!(t11() as *mut (), p as *mut ());
203 assert_eq!(t12(), C);
204 assert_eq!(t13(), C2);
205 assert_eq!(t13_2(), C3);
207 assert_eq!(t14()(), <S as X>::hoy2());
208 assert_eq!(t15()(&s), S::hey2(&s));
209 assert_eq!(t16()(10u32, 20u32), F::f(10u32, 20u32));
210 assert_eq!(t17()(30u32, 10u64), F::f(30u32, 10u64));
211 assert_eq!(t18()(50u64, 5u64), F::f(50u64, 5u64));
212 assert_eq!(t19()(322u64, 2u32), F::f(322u64, 2u32));
213 assert_eq!(t20()(123u64, 38u32), <u32 as T<_, _>>::staticmeth(123, 38));
214 assert_eq!(t21(), Unit);
215 assert_eq!(t22(), None);
216 assert_eq!(t23(), (CEnum::A, CEnum::B));
217 assert_eq!(t24(), C4);