]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/lint-visible-private-types.rs
Fix the fallout
[rust.git] / src / test / compile-fail / lint-visible-private-types.rs
1 // Copyright 2014 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 #![allow(dead_code)]
12 #![crate_type="lib"]
13
14 use std::marker;
15
16 struct Private<T>(marker::PhantomData<T>);
17 pub struct Public<T>(marker::PhantomData<T>);
18
19 impl Private<Public<isize>> {
20     pub fn a(&self) -> Private<isize> { panic!() }
21     fn b(&self) -> Private<isize> { panic!() }
22
23     pub fn c() -> Private<isize> { panic!() }
24     fn d() -> Private<isize> { panic!() }
25 }
26 impl Private<isize> {
27     pub fn e(&self) -> Private<isize> { panic!() }
28     fn f(&self) -> Private<isize> { panic!() }
29 }
30
31 impl Public<Private<isize>> {
32     pub fn a(&self) -> Private<isize> { panic!() }
33     fn b(&self) -> Private<isize> { panic!() }
34
35     pub fn c() -> Private<isize> { panic!() }
36     fn d() -> Private<isize> { panic!() }
37 }
38 impl Public<isize> {
39     pub fn e(&self) -> Private<isize> { panic!() } //~ ERROR private type in exported type signature
40     fn f(&self) -> Private<isize> { panic!() }
41 }
42
43 pub fn x(_: Private<isize>) {} //~ ERROR private type in exported type signature
44
45 fn y(_: Private<isize>) {}
46
47
48 pub struct Foo {
49     pub x: Private<isize>, //~ ERROR private type in exported type signature
50     y: Private<isize>
51 }
52
53 struct Bar {
54     x: Private<isize>,
55 }
56
57 pub enum Baz {
58     Baz1(Private<isize>), //~ ERROR private type in exported type signature
59     Baz2 {
60         y: Private<isize> //~ ERROR private type in exported type signature
61     },
62 }
63
64 enum Qux {
65     Qux1(Private<isize>),
66     Qux2 {
67         x: Private<isize>,
68     }
69 }
70
71 pub trait PubTrait {
72     fn foo(&self) -> Private<isize> { panic!( )} //~ ERROR private type in exported type signature
73     fn bar(&self) -> Private<isize>; //~ ERROR private type in exported type signature
74     fn baz() -> Private<isize>; //~ ERROR private type in exported type signature
75 }
76
77 impl PubTrait for Public<isize> {
78     fn bar(&self) -> Private<isize> { panic!() } //~ ERROR private type in exported type signature
79     fn baz() -> Private<isize> { panic!() } //~ ERROR private type in exported type signature
80 }
81 impl PubTrait for Public<Private<isize>> {
82     fn bar(&self) -> Private<isize> { panic!() }
83     fn baz() -> Private<isize> { panic!() }
84 }
85
86 impl PubTrait for Private<isize> {
87     fn bar(&self) -> Private<isize> { panic!() }
88     fn baz() -> Private<isize> { panic!() }
89 }
90 impl PubTrait for (Private<isize>,) {
91     fn bar(&self) -> Private<isize> { panic!() }
92     fn baz() -> Private<isize> { panic!() }
93 }
94
95
96 trait PrivTrait {
97     fn foo(&self) -> Private<isize> { panic!( )}
98     fn bar(&self) -> Private<isize>;
99 }
100 impl PrivTrait for Private<isize> {
101     fn bar(&self) -> Private<isize> { panic!() }
102 }
103 impl PrivTrait for (Private<isize>,) {
104     fn bar(&self) -> Private<isize> { panic!() }
105 }
106
107 pub trait ParamTrait<T> {
108     fn foo() -> T;
109 }
110
111 impl ParamTrait<Private<isize>>
112    for Public<isize> {
113     fn foo() -> Private<isize> { panic!() }
114 }
115
116 impl ParamTrait<Private<isize>> for Private<isize> {
117     fn foo() -> Private<isize> { panic!( )}
118 }
119
120 impl<T: ParamTrait<Private<isize>>>  //~ ERROR private type in exported type signature
121      ParamTrait<T> for Public<i8> {
122     fn foo() -> T { panic!() }
123 }