From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/nll/ty-outlives/issue-53789-1.rs | 87 ++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/test/ui/nll/ty-outlives/issue-53789-1.rs (limited to 'src/test/ui/nll/ty-outlives/issue-53789-1.rs') diff --git a/src/test/ui/nll/ty-outlives/issue-53789-1.rs b/src/test/ui/nll/ty-outlives/issue-53789-1.rs new file mode 100644 index 000000000..a5201d4bb --- /dev/null +++ b/src/test/ui/nll/ty-outlives/issue-53789-1.rs @@ -0,0 +1,87 @@ +// Regression test for #53789. +// +// check-pass + +use std::collections::BTreeMap; + +trait ValueTree { + type Value; +} + +trait Strategy { + type Value: ValueTree; +} + +type StrategyFor = StrategyType<'static, A>; +type StrategyType<'a, A> = >::Strategy; + +impl Strategy for (K, V) { + type Value = TupleValueTree<(K, V)>; +} + +impl ValueTree for TupleValueTree<(K, V)> { + type Value = BTreeMapValueTree; +} + +struct TupleValueTree { + tree: T, +} + +struct BTreeMapStrategy(std::marker::PhantomData<(K, V)>) +where + K: Strategy, + V: Strategy; + +struct BTreeMapValueTree(std::marker::PhantomData<(K, V)>) +where + K: ValueTree, + V: ValueTree; + +impl Strategy for BTreeMapStrategy +where + K: Strategy, + V: Strategy, +{ + type Value = BTreeMapValueTree; +} + +impl ValueTree for BTreeMapValueTree +where + K: ValueTree, + V: ValueTree, +{ + type Value = BTreeMap; +} + +trait Arbitrary<'a>: Sized { + fn arbitrary_with(args: Self::Parameters) -> Self::Strategy; + type Parameters; + type Strategy: Strategy; + type ValueTree: ValueTree; +} + +impl<'a, A, B> Arbitrary<'a> for BTreeMap +where + A: Arbitrary<'static>, + B: Arbitrary<'static>, + StrategyFor: 'static, + StrategyFor: 'static, +{ + type ValueTree = ::Value; + type Parameters = (A::Parameters, B::Parameters); + type Strategy = BTreeMapStrategy; + fn arbitrary_with(args: Self::Parameters) -> BTreeMapStrategy { + let (a, b) = args; + btree_map(any_with::(a), any_with::(b)) + } +} + +fn btree_map(key: K, value: V) -> BTreeMapStrategy { + unimplemented!() +} + +fn any_with<'a, A: Arbitrary<'a>>(args: A::Parameters) -> StrategyType<'a, A> { + unimplemented!() +} + +fn main() { } -- cgit v1.2.3