]> git.lizzy.rs Git - rust.git/blob - src/test/run-pass/monomorphized-callees-with-ty-params-3314.rs
Auto merge of #22541 - Manishearth:rollup, r=Gankro
[rust.git] / src / test / run-pass / monomorphized-callees-with-ty-params-3314.rs
1 // Copyright 2012 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 use std::marker::MarkerTrait;
12
13 trait Serializer : MarkerTrait {
14 }
15
16 trait Serializable {
17     fn serialize<S:Serializer>(&self, s: S);
18 }
19
20 impl Serializable for int {
21     fn serialize<S:Serializer>(&self, _s: S) { }
22 }
23
24 struct F<A> { a: A }
25
26 impl<A:Serializable> Serializable for F<A> {
27     fn serialize<S:Serializer>(&self, s: S) {
28         self.a.serialize(s);
29     }
30 }
31
32 impl Serializer for int {
33 }
34
35 pub fn main() {
36     let foo = F { a: 1 };
37     foo.serialize(1);
38
39     let bar = F { a: F {a: 1 } };
40     bar.serialize(2);
41 }