]> git.lizzy.rs Git - rust.git/blob - src/test/ui/associated-types/associated-types-projection-in-object-type.rs
Merge commit '4f3ab69ea0a0908260944443c739426cc384ae1a' into clippyup
[rust.git] / src / test / ui / associated-types / associated-types-projection-in-object-type.rs
1 // run-pass
2 #![allow(dead_code)]
3 #![allow(unused_imports)]
4 // Corrected regression test for #20831. The original did not compile.
5 // When fixed, it revealed another problem concerning projections that
6 // appear in associated type bindings in object types, which were not
7 // being properly flagged.
8
9 // pretty-expanded FIXME #23616
10
11 use std::ops::{Shl, Shr};
12 use std::cell::RefCell;
13
14 pub trait Subscriber {
15     type Input;
16
17     fn dummy(&self) { }
18 }
19
20 pub trait Publisher<'a> {
21     type Output;
22     fn subscribe(&mut self, _: Box<dyn Subscriber<Input=Self::Output> + 'a>);
23 }
24
25 pub trait Processor<'a> : Subscriber + Publisher<'a> { }
26
27 impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { }
28
29 struct MyStruct<'a> {
30     sub: Box<dyn Subscriber<Input=u64> + 'a>
31 }
32
33 impl<'a> Publisher<'a> for MyStruct<'a> {
34     type Output = u64;
35     fn subscribe(&mut self, t : Box<dyn Subscriber<Input=u64> + 'a>) {
36         self.sub = t;
37     }
38 }
39
40 fn main() {}