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