summaryrefslogtreecommitdiffstats
path: root/src/test/ui/associated-type-bounds/bad-bounds-on-assoc-in-trait.rs
blob: d180de9be3bf310896f4f65b601240a691ebb9da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// NOTE: rustc cannot currently handle bounds of the form `for<'a> <Foo as Bar<'a>>::Assoc: Baz`.
// This should hopefully be fixed with Chalk.

#![feature(associated_type_bounds)]

use std::fmt::Debug;
use std::iter::Once;

trait Lam<Binder> {
    type App;
}

#[derive(Clone)]
struct L1;
impl<'a> Lam<&'a u8> for L1 {
    type App = u8;
}

#[derive(Clone)]
struct L2;
impl<'a, 'b> Lam<&'a &'b u8> for L2 {
    type App = u8;
}

trait Case1 {
    type C: Clone + Iterator<Item: Send + Iterator<Item: for<'a> Lam<&'a u8, App: Debug>> + Sync>;
    //~^ ERROR `<<Self as Case1>::C as Iterator>::Item` is not an iterator
    //~| ERROR `<<Self as Case1>::C as Iterator>::Item` cannot be sent between threads safely
    //~| ERROR `<<Self as Case1>::C as Iterator>::Item` cannot be shared between threads safely
}

pub struct S1;
impl Case1 for S1 {
    type C = Once<Once<L1>>;
}

fn assume_case1<T: Case1>() {
    fn assert_a<_0, A>()
    where
        A: Iterator<Item = _0>,
        _0: Debug,
    {
    }
    assert_a::<_, T::A>();

    fn assert_b<_0, B>()
    where
        B: Iterator<Item = _0>,
        _0: 'static,
    {
    }
    assert_b::<_, T::B>();

    fn assert_c<_0, _1, _2, C>()
    where
        C: Clone + Iterator<Item = _2>,
        _2: Send + Iterator<Item = _1>,
        _1: for<'a> Lam<&'a u8, App = _0>,
        _0: Debug,
    {
    }
    assert_c::<_, _, _, T::C>();
}

fn main() {
    assume_case1(S1);
}