|
| 1 | +//@ check-pass |
| 2 | + |
| 3 | +fn factory0<T: Factory>() { |
| 4 | + let _: T::Output::Category; |
| 5 | +} |
| 6 | + |
| 7 | +fn factory1<T: Factory<Output: Product<Category = u16>>>(category: u16) { |
| 8 | + let _: T::Output::Category = category; |
| 9 | +} |
| 10 | + |
| 11 | +fn factory2<T: Factory>(_: T::Output::Category) {} |
| 12 | + |
| 13 | +trait Factory { |
| 14 | + type Output: Product; |
| 15 | +} |
| 16 | + |
| 17 | +impl Factory for () { |
| 18 | + type Output = u128; |
| 19 | +} |
| 20 | + |
| 21 | +trait Product { |
| 22 | + type Category; |
| 23 | +} |
| 24 | + |
| 25 | +impl Product for u128 { |
| 26 | + type Category = u16; |
| 27 | +} |
| 28 | + |
| 29 | +///////////////////////// |
| 30 | + |
| 31 | +fn chain<C: Chain<Link = C>>(chain: C) { |
| 32 | + let _: C::Link::Link::Link::Link::Link = chain; |
| 33 | +} |
| 34 | + |
| 35 | +trait Chain { type Link: Chain; } |
| 36 | + |
| 37 | +impl Chain for () { |
| 38 | + type Link = Self; |
| 39 | +} |
| 40 | + |
| 41 | +///////////////////////// |
| 42 | + |
| 43 | +fn scope<'r, T: Main<'static, (i32, U), 1>, U, const Q: usize>() { |
| 44 | + let _: T::Next<'r, (), Q>::Final; |
| 45 | +} |
| 46 | + |
| 47 | +trait Main<'a, T, const N: usize> { |
| 48 | + type Next<'b, U, const M: usize>: Aux<'a, 'b, (T, U), N, M>; |
| 49 | +} |
| 50 | + |
| 51 | +impl<'a, T, const N: usize> Main<'a, T, N> for () { |
| 52 | + type Next<'_b, _U, const _M: usize> = (); |
| 53 | +} |
| 54 | + |
| 55 | +trait Aux<'a, 'b, T, const N: usize, const M: usize> { |
| 56 | + type Final; |
| 57 | +} |
| 58 | + |
| 59 | +impl<'a, 'b, T, const N: usize, const M: usize> Aux<'a, 'b, T, N, M> for () { |
| 60 | + type Final = [[(T, &'a (), &'b ()); N]; M]; |
| 61 | +} |
| 62 | + |
| 63 | +///////////////////////// |
| 64 | + |
| 65 | +fn main() { |
| 66 | + factory0::<()>(); |
| 67 | + factory1::<()>(360); |
| 68 | + factory2::<()>(720); |
| 69 | + let _: <() as Factory>::Output::Category; |
| 70 | + |
| 71 | + chain(()); |
| 72 | + let _: <() as Chain>::Link::Link::Link; |
| 73 | + |
| 74 | + scope::<(), bool, 32>(); |
| 75 | +} |
0 commit comments