]> git.proxmox.com Git - rustc.git/blob - src/test/ui/nll/ty-outlives/issue-53789-1.rs
New upstream version 1.41.1+dfsg1
[rustc.git] / src / test / ui / nll / ty-outlives / issue-53789-1.rs
1 // Regression test for #53789.
2 //
3 // check-pass
4
5 use std::collections::BTreeMap;
6
7 trait ValueTree {
8 type Value;
9 }
10
11 trait Strategy {
12 type Value: ValueTree;
13 }
14
15 type StrategyFor<A> = StrategyType<'static, A>;
16 type StrategyType<'a, A> = <A as Arbitrary<'a>>::Strategy;
17
18 impl<K: ValueTree, V: ValueTree> Strategy for (K, V) {
19 type Value = TupleValueTree<(K, V)>;
20 }
21
22 impl<K: ValueTree, V: ValueTree> ValueTree for TupleValueTree<(K, V)> {
23 type Value = BTreeMapValueTree<K, V>;
24 }
25
26 struct TupleValueTree<T> {
27 tree: T,
28 }
29
30 struct BTreeMapStrategy<K, V>(std::marker::PhantomData<(K, V)>)
31 where
32 K: Strategy,
33 V: Strategy;
34
35 struct BTreeMapValueTree<K, V>(std::marker::PhantomData<(K, V)>)
36 where
37 K: ValueTree,
38 V: ValueTree;
39
40 impl<K, V> Strategy for BTreeMapStrategy<K, V>
41 where
42 K: Strategy,
43 V: Strategy,
44 {
45 type Value = BTreeMapValueTree<K::Value, V::Value>;
46 }
47
48 impl<K, V> ValueTree for BTreeMapValueTree<K, V>
49 where
50 K: ValueTree,
51 V: ValueTree,
52 {
53 type Value = BTreeMap<K::Value, V::Value>;
54 }
55
56 trait Arbitrary<'a>: Sized {
57 fn arbitrary_with(args: Self::Parameters) -> Self::Strategy;
58 type Parameters;
59 type Strategy: Strategy<Value = Self::ValueTree>;
60 type ValueTree: ValueTree<Value = Self>;
61 }
62
63 impl<'a, A, B> Arbitrary<'a> for BTreeMap<A, B>
64 where
65 A: Arbitrary<'static>,
66 B: Arbitrary<'static>,
67 StrategyFor<A>: 'static,
68 StrategyFor<B>: 'static,
69 {
70 type ValueTree = <Self::Strategy as Strategy>::Value;
71 type Parameters = (A::Parameters, B::Parameters);
72 type Strategy = BTreeMapStrategy<A::Strategy, B::Strategy>;
73 fn arbitrary_with(args: Self::Parameters) -> BTreeMapStrategy<A::Strategy, B::Strategy> {
74 let (a, b) = args;
75 btree_map(any_with::<A>(a), any_with::<B>(b))
76 }
77 }
78
79 fn btree_map<K: Strategy + 'static, V: Strategy>(key: K, value: V) -> BTreeMapStrategy<K, V> {
80 unimplemented!()
81 }
82
83 fn any_with<'a, A: Arbitrary<'a>>(args: A::Parameters) -> StrategyType<'a, A> {
84 unimplemented!()
85 }
86
87 fn main() { }