]> git.proxmox.com Git - rustc.git/blame - src/test/run-pass/associated-types-projection-in-object-type.rs
New upstream version 1.20.0+dfsg1
[rustc.git] / src / test / run-pass / associated-types-projection-in-object-type.rs
CommitLineData
85aaf69f
SL
1// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2// file at the top-level directory of this distribution and at
3// http://rust-lang.org/COPYRIGHT.
4//
5// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8// option. This file may not be copied, modified, or distributed
9// except according to those terms.
10
11// Corrected regression test for #20831. The original did not compile.
12// When fixed, it revealed another problem concerning projections that
13// appear in associated type bindings in object types, which were not
14// being properly flagged.
15
c34b1796
AL
16// pretty-expanded FIXME #23616
17
85aaf69f
SL
18use std::ops::{Shl, Shr};
19use std::cell::RefCell;
20
21pub trait Subscriber {
22 type Input;
23
24 fn dummy(&self) { }
25}
26
27pub trait Publisher<'a> {
28 type Output;
041b39d2 29 fn subscribe(&mut self, _: Box<Subscriber<Input=Self::Output> + 'a>);
85aaf69f
SL
30}
31
32pub trait Processor<'a> : Subscriber + Publisher<'a> { }
33
34impl<'a, P> Processor<'a> for P where P : Subscriber + Publisher<'a> { }
35
36struct MyStruct<'a> {
37 sub: Box<Subscriber<Input=u64> + 'a>
38}
39
40impl<'a> Publisher<'a> for MyStruct<'a> {
41 type Output = u64;
42 fn subscribe(&mut self, t : Box<Subscriber<Input=u64> + 'a>) {
43 self.sub = t;
44 }
45}
46
47fn main() {}