2 // aux-build:mir_external_refs.rs
4 extern crate mir_external_refs as ext;
6 struct S(#[allow(unused_tuple_struct_fields)] u8);
7 #[derive(Debug, PartialEq, Eq)]
12 fn hey2(&self) -> u8 { 44 }
16 fn hoy(&self) -> u8 { 43 }
17 fn hoy2() -> u8 { 45 }
21 fn f(self, other: U) -> u64;
25 fn f(self, other: u32) -> u64 { self as u64 + other as u64 }
29 fn f(self, other: u64) -> u64 { self as u64 - other }
33 fn f(self, other: u64) -> u64 { self * other }
37 fn f(self, other: u32) -> u64 { self ^ other as u64 }
41 fn staticmeth(i: I, o: O) -> (I, O) { (i, o) }
44 impl<I, O> T<I, O> for O {}
49 U(#[allow(unused_tuple_struct_fields)] u8)
52 #[derive(PartialEq, Debug, Eq)]
59 const C2: [u8; 5] = [42; 5];
60 const C3: [u8; 3] = [42, 41, 40];
61 const C4: fn(u8) -> S = S;
67 fn parametric<T>(u: T) -> T {
75 fn t2() -> fn(u8)->E {
79 fn t3() -> fn(u8)->S {
87 fn t5() -> fn(&S)-> u8 {
96 fn t7() -> fn(u8)->ext::E {
100 fn t8() -> fn(u8)->ext::S {
104 fn t9() -> fn()->u8 {
108 fn t10() -> fn(&ext::S)->u8 {
109 <ext::S as ext::X>::hoy
112 fn t11() -> fn(u8)->u8 {
120 fn t13() -> [u8; 5] {
124 fn t13_2() -> [u8; 3] {
128 fn t14() -> fn()-> u8 {
132 fn t15() -> fn(&S)-> u8 {
136 fn t16() -> fn(u32, u32)->u64 {
140 fn t17() -> fn(u32, u64)->u64 {
144 fn t18() -> fn(u64, u64)->u64 {
148 fn t19() -> fn(u64, u32)->u64 {
152 fn t20() -> fn(u64, u32)->(u64, u32) {
153 <u32 as T<_, _>>::staticmeth
160 fn t22() -> Option<u8> {
164 fn t23() -> (CEnum, CEnum) {
168 fn t24() -> fn(u8) -> S {
173 assert_eq!(t1()(), regular());
175 assert_eq!(t2() as *mut (), E::U as *mut ());
176 assert_eq!(t3() as *mut (), S as *mut ());
178 assert_eq!(t4()(), S::hey());
180 assert_eq!(t5()(&s), <S as X>::hoy(&s));
183 assert_eq!(t6()(), ext::regular_fn());
184 assert_eq!(t7() as *mut (), ext::E::U as *mut ());
185 assert_eq!(t8() as *mut (), ext::S as *mut ());
187 assert_eq!(t9()(), ext::S::hey());
188 let sext = ext::S(6);
189 assert_eq!(t10()(&sext), <ext::S as ext::X>::hoy(&sext));
191 let p = parametric::<u8>;
192 assert_eq!(t11() as *mut (), p as *mut ());
194 assert_eq!(t12(), C);
195 assert_eq!(t13(), C2);
196 assert_eq!(t13_2(), C3);
198 assert_eq!(t14()(), <S as X>::hoy2());
199 assert_eq!(t15()(&s), S::hey2(&s));
200 assert_eq!(t16()(10u32, 20u32), F::f(10u32, 20u32));
201 assert_eq!(t17()(30u32, 10u64), F::f(30u32, 10u64));
202 assert_eq!(t18()(50u64, 5u64), F::f(50u64, 5u64));
203 assert_eq!(t19()(322u64, 2u32), F::f(322u64, 2u32));
204 assert_eq!(t20()(123u64, 38u32), <u32 as T<_, _>>::staticmeth(123, 38));
205 assert_eq!(t21(), Unit);
206 assert_eq!(t22(), None);
207 assert_eq!(t23(), (CEnum::A, CEnum::B));
208 assert_eq!(t24(), C4);