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