]> git.lizzy.rs Git - rust.git/blob - src/test/ui/namespace/namespace-mix.rs
c1c724fc431c7c30e497b3daf456b9731bdf97cf
[rust.git] / src / test / ui / namespace / namespace-mix.rs
1 // Copyright 2016 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 // aux-build:namespace-mix.rs
12
13 extern crate namespace_mix;
14 use namespace_mix::*;
15
16 mod c {
17     pub struct S {}
18     pub struct TS();
19     pub struct US;
20     pub enum E {
21         V {},
22         TV(),
23         UV,
24     }
25
26     pub struct Item;
27 }
28
29 // Use something emitting the type argument name, e.g. unsatisfied bound.
30 trait Impossible {}
31 fn check<T: Impossible>(_: T) {}
32
33 mod m1 {
34     pub use ::c::*;
35     pub type S = ::c::Item;
36 }
37 mod m2 {
38     pub use ::c::*;
39     pub const S: ::c::Item = ::c::Item;
40 }
41
42 fn f12() {
43     check(m1::S{}); //~ ERROR c::Item
44     check(m1::S); //~ ERROR expected value, found type alias `m1::S`
45     check(m2::S{}); //~ ERROR c::S
46     check(m2::S); //~ ERROR c::Item
47 }
48 fn xf12() {
49     check(xm1::S{}); //~ ERROR c::Item
50     check(xm1::S); //~ ERROR expected value, found type alias `xm1::S`
51     check(xm2::S{}); //~ ERROR c::S
52     check(xm2::S); //~ ERROR c::Item
53 }
54
55 mod m3 {
56     pub use ::c::*;
57     pub type TS = ::c::Item;
58 }
59 mod m4 {
60     pub use ::c::*;
61     pub const TS: ::c::Item = ::c::Item;
62 }
63
64 fn f34() {
65     check(m3::TS{}); //~ ERROR c::Item
66     check(m3::TS); //~ ERROR c::TS
67     check(m4::TS{}); //~ ERROR c::TS
68     check(m4::TS); //~ ERROR c::Item
69 }
70 fn xf34() {
71     check(xm3::TS{}); //~ ERROR c::Item
72     check(xm3::TS); //~ ERROR c::TS
73     check(xm4::TS{}); //~ ERROR c::TS
74     check(xm4::TS); //~ ERROR c::Item
75 }
76
77 mod m5 {
78     pub use ::c::*;
79     pub type US = ::c::Item;
80 }
81 mod m6 {
82     pub use ::c::*;
83     pub const US: ::c::Item = ::c::Item;
84 }
85
86 fn f56() {
87     check(m5::US{}); //~ ERROR c::Item
88     check(m5::US); //~ ERROR c::US
89     check(m6::US{}); //~ ERROR c::US
90     check(m6::US); //~ ERROR c::Item
91 }
92 fn xf56() {
93     check(xm5::US{}); //~ ERROR c::Item
94     check(xm5::US); //~ ERROR c::US
95     check(xm6::US{}); //~ ERROR c::US
96     check(xm6::US); //~ ERROR c::Item
97 }
98
99 mod m7 {
100     pub use ::c::E::*;
101     pub type V = ::c::Item;
102 }
103 mod m8 {
104     pub use ::c::E::*;
105     pub const V: ::c::Item = ::c::Item;
106 }
107
108 fn f78() {
109     check(m7::V{}); //~ ERROR c::Item
110     check(m7::V); //~ ERROR expected value, found struct variant `m7::V`
111     check(m8::V{}); //~ ERROR c::E
112     check(m8::V); //~ ERROR c::Item
113 }
114 fn xf78() {
115     check(xm7::V{}); //~ ERROR c::Item
116     check(xm7::V); //~ ERROR expected value, found struct variant `xm7::V`
117     check(xm8::V{}); //~ ERROR c::E
118     check(xm8::V); //~ ERROR c::Item
119 }
120
121 mod m9 {
122     pub use ::c::E::*;
123     pub type TV = ::c::Item;
124 }
125 mod mA {
126     pub use ::c::E::*;
127     pub const TV: ::c::Item = ::c::Item;
128 }
129
130 fn f9A() {
131     check(m9::TV{}); //~ ERROR c::Item
132     check(m9::TV); //~ ERROR c::E
133     check(mA::TV{}); //~ ERROR c::E
134     check(mA::TV); //~ ERROR c::Item
135 }
136 fn xf9A() {
137     check(xm9::TV{}); //~ ERROR c::Item
138     check(xm9::TV); //~ ERROR c::E
139     check(xmA::TV{}); //~ ERROR c::E
140     check(xmA::TV); //~ ERROR c::Item
141 }
142
143 mod mB {
144     pub use ::c::E::*;
145     pub type UV = ::c::Item;
146 }
147 mod mC {
148     pub use ::c::E::*;
149     pub const UV: ::c::Item = ::c::Item;
150 }
151
152 fn fBC() {
153     check(mB::UV{}); //~ ERROR c::Item
154     check(mB::UV); //~ ERROR c::E
155     check(mC::UV{}); //~ ERROR c::E
156     check(mC::UV); //~ ERROR c::Item
157 }
158 fn xfBC() {
159     check(xmB::UV{}); //~ ERROR c::Item
160     check(xmB::UV); //~ ERROR c::E
161     check(xmC::UV{}); //~ ERROR c::E
162     check(xmC::UV); //~ ERROR c::Item
163 }
164
165 fn main() {}