]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs
Auto merge of #103894 - mati865:gnullvm-libunwind-changes, r=thomcc
[rust.git] / src / test / ui / associated-type-bounds / bad-bounds-on-assoc-in-trait.rs
1 // NOTE: rustc cannot currently handle bounds of the form `for<'a> <Foo as Bar<'a>>::Assoc: Baz`.
2 // This should hopefully be fixed with Chalk.
3
4 #![feature(associated_type_bounds)]
5
6 use std::fmt::Debug;
7 use std::iter::Once;
8
9 trait Lam<Binder> {
10     type App;
11 }
12
13 #[derive(Clone)]
14 struct L1;
15 impl<'a> Lam<&'a u8> for L1 {
16     type App = u8;
17 }
18
19 #[derive(Clone)]
20 struct L2;
21 impl<'a, 'b> Lam<&'a &'b u8> for L2 {
22     type App = u8;
23 }
24
25 trait Case1 {
26     type C: Clone + Iterator<Item: Send + Iterator<Item: for<'a> Lam<&'a u8, App: Debug>> + Sync>;
27     //~^ ERROR `<<Self as Case1>::C as Iterator>::Item` is not an iterator
28     //~| ERROR `<<Self as Case1>::C as Iterator>::Item` cannot be sent between threads safely
29     //~| ERROR `<<Self as Case1>::C as Iterator>::Item` cannot be shared between threads safely
30 }
31
32 pub struct S1;
33 impl Case1 for S1 {
34     type C = Once<Once<L1>>;
35 }
36
37 fn assume_case1<T: Case1>() {
38     fn assert_a<_0, A>()
39     where
40         A: Iterator<Item = _0>,
41         _0: Debug,
42     {
43     }
44     assert_a::<_, T::A>();
45
46     fn assert_b<_0, B>()
47     where
48         B: Iterator<Item = _0>,
49         _0: 'static,
50     {
51     }
52     assert_b::<_, T::B>();
53
54     fn assert_c<_0, _1, _2, C>()
55     where
56         C: Clone + Iterator<Item = _2>,
57         _2: Send + Iterator<Item = _1>,
58         _1: for<'a> Lam<&'a u8, App = _0>,
59         _0: Debug,
60     {
61     }
62     assert_c::<_, _, _, T::C>();
63 }
64
65 fn main() {
66     assume_case1(S1);
67 }