]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-type-bounds/bounds-on-assoc-in-trait.rs
Auto merge of #103894 - mati865:gnullvm-libunwind-changes, r=thomcc
[rust.git] / src / test / ui / associated-type-bounds / bounds-on-assoc-in-trait.rs
1 #![feature(associated_type_bounds)]
2
3 use std::fmt::Debug;
4 use std::iter::Empty;
5 use std::ops::Range;
6
7 trait Lam<Binder> { type App; }
8
9 #[derive(Clone)]
10 struct L1;
11 impl<'a> Lam<&'a u8> for L1 { type App = u8; }
12
13 #[derive(Clone)]
14 struct L2;
15 impl<'a, 'b> Lam<&'a &'b u8> for L2 { type App = u8; }
16
17 trait Case1 {
18     type A: Iterator<Item: Debug>;
19     //~^ ERROR `<<Self as Case1>::A as Iterator>::Item` doesn't implement `Debug`
20
21     type B: Iterator<Item: 'static>;
22 }
23
24 pub struct S1;
25 impl Case1 for S1 {
26     type A = Empty<String>;
27     type B = Range<u16>;
28 }
29
30 // Ensure we don't have opaque `impl Trait` desugaring:
31
32 // What is this supposed to mean? Rustc currently lowers `: Default` in the
33 // bounds of `Out`, but trait selection can't find the bound since it applies
34 // to a type other than `Self::Out`.
35 pub trait Foo { type Out: Baz<Assoc: Default>; }
36 //~^ ERROR trait bound `<<Self as Foo>::Out as Baz>::Assoc: Default` is not satisfied
37 pub trait Baz { type Assoc; }
38
39 #[derive(Default)]
40 struct S2;
41 #[derive(Default)]
42 struct S3;
43 struct S4;
44 struct S5;
45 struct S6;
46 struct S7;
47
48 impl Foo for S6 { type Out = S4; }
49 impl Foo for S7 { type Out = S5; }
50
51 impl Baz for S4 { type Assoc = S2; }
52 impl Baz for S5 { type Assoc = S3; }
53
54 fn main() {}