]>
Commit | Line | Data |
---|---|---|
223e47cc LB |
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 | fn main() { | |
12 | ||
13 | // the smallest positive values that need these types | |
14 | let a8: i8 = 8; | |
15 | let a16: i16 = 128; | |
16 | let a32: i32 = 32_768; | |
17 | let a64: i64 = 2_147_483_648; | |
18 | ||
19 | // the smallest negative values that need these types | |
20 | let c8: i8 = -9; | |
21 | let c16: i16 = -129; | |
22 | let c32: i32 = -32_769; | |
23 | let c64: i64 = -2_147_483_649; | |
24 | ||
25 | fn id_i8(n: i8) -> i8 { n } | |
26 | fn id_i16(n: i16) -> i16 { n } | |
27 | fn id_i32(n: i32) -> i32 { n } | |
28 | fn id_i64(n: i64) -> i64 { n } | |
29 | ||
30 | // the smallest values that need these types | |
31 | let b8: u8 = 16; | |
32 | let b16: u16 = 256; | |
33 | let b32: u32 = 65_536; | |
34 | let b64: u64 = 4_294_967_296; | |
35 | ||
36 | fn id_u8(n: u8) -> u8 { n } | |
37 | fn id_u16(n: u16) -> u16 { n } | |
38 | fn id_u32(n: u32) -> u32 { n } | |
39 | fn id_u64(n: u64) -> u64 { n } | |
40 | ||
41 | id_i8(a8); // ok | |
85aaf69f SL |
42 | id_i8(a16); |
43 | //~^ ERROR mismatched types | |
44 | //~| expected `i8` | |
45 | //~| found `i16` | |
85aaf69f SL |
46 | id_i8(a32); |
47 | //~^ ERROR mismatched types | |
48 | //~| expected `i8` | |
49 | //~| found `i32` | |
85aaf69f SL |
50 | id_i8(a64); |
51 | //~^ ERROR mismatched types | |
52 | //~| expected `i8` | |
53 | //~| found `i64` | |
223e47cc | 54 | |
85aaf69f SL |
55 | id_i16(a8); |
56 | //~^ ERROR mismatched types | |
57 | //~| expected `i16` | |
58 | //~| found `i8` | |
223e47cc | 59 | id_i16(a16); // ok |
85aaf69f SL |
60 | id_i16(a32); |
61 | //~^ ERROR mismatched types | |
62 | //~| expected `i16` | |
63 | //~| found `i32` | |
85aaf69f SL |
64 | id_i16(a64); |
65 | //~^ ERROR mismatched types | |
66 | //~| expected `i16` | |
67 | //~| found `i64` | |
223e47cc | 68 | |
85aaf69f SL |
69 | id_i32(a8); |
70 | //~^ ERROR mismatched types | |
71 | //~| expected `i32` | |
72 | //~| found `i8` | |
85aaf69f SL |
73 | id_i32(a16); |
74 | //~^ ERROR mismatched types | |
75 | //~| expected `i32` | |
76 | //~| found `i16` | |
223e47cc | 77 | id_i32(a32); // ok |
85aaf69f SL |
78 | id_i32(a64); |
79 | //~^ ERROR mismatched types | |
80 | //~| expected `i32` | |
81 | //~| found `i64` | |
223e47cc | 82 | |
85aaf69f SL |
83 | id_i64(a8); |
84 | //~^ ERROR mismatched types | |
85 | //~| expected `i64` | |
86 | //~| found `i8` | |
85aaf69f SL |
87 | id_i64(a16); |
88 | //~^ ERROR mismatched types | |
89 | //~| expected `i64` | |
90 | //~| found `i16` | |
85aaf69f SL |
91 | id_i64(a32); |
92 | //~^ ERROR mismatched types | |
93 | //~| expected `i64` | |
94 | //~| found `i32` | |
223e47cc LB |
95 | id_i64(a64); // ok |
96 | ||
97 | id_i8(c8); // ok | |
85aaf69f SL |
98 | id_i8(c16); |
99 | //~^ ERROR mismatched types | |
100 | //~| expected `i8` | |
101 | //~| found `i16` | |
85aaf69f SL |
102 | id_i8(c32); |
103 | //~^ ERROR mismatched types | |
104 | //~| expected `i8` | |
105 | //~| found `i32` | |
85aaf69f SL |
106 | id_i8(c64); |
107 | //~^ ERROR mismatched types | |
108 | //~| expected `i8` | |
109 | //~| found `i64` | |
223e47cc | 110 | |
85aaf69f SL |
111 | id_i16(c8); |
112 | //~^ ERROR mismatched types | |
113 | //~| expected `i16` | |
114 | //~| found `i8` | |
223e47cc | 115 | id_i16(c16); // ok |
85aaf69f SL |
116 | id_i16(c32); |
117 | //~^ ERROR mismatched types | |
118 | //~| expected `i16` | |
119 | //~| found `i32` | |
85aaf69f SL |
120 | id_i16(c64); |
121 | //~^ ERROR mismatched types | |
122 | //~| expected `i16` | |
123 | //~| found `i64` | |
223e47cc | 124 | |
85aaf69f SL |
125 | id_i32(c8); |
126 | //~^ ERROR mismatched types | |
127 | //~| expected `i32` | |
128 | //~| found `i8` | |
85aaf69f SL |
129 | id_i32(c16); |
130 | //~^ ERROR mismatched types | |
131 | //~| expected `i32` | |
132 | //~| found `i16` | |
223e47cc | 133 | id_i32(c32); // ok |
85aaf69f SL |
134 | id_i32(c64); |
135 | //~^ ERROR mismatched types | |
136 | //~| expected `i32` | |
137 | //~| found `i64` | |
223e47cc | 138 | |
85aaf69f SL |
139 | id_i64(a8); |
140 | //~^ ERROR mismatched types | |
141 | //~| expected `i64` | |
142 | //~| found `i8` | |
85aaf69f SL |
143 | id_i64(a16); |
144 | //~^ ERROR mismatched types | |
145 | //~| expected `i64` | |
85aaf69f SL |
146 | //~| found i16 |
147 | id_i64(a32); | |
148 | //~^ ERROR mismatched types | |
149 | //~| expected `i64` | |
150 | //~| found `i32` | |
223e47cc LB |
151 | id_i64(a64); // ok |
152 | ||
153 | id_u8(b8); // ok | |
85aaf69f SL |
154 | id_u8(b16); |
155 | //~^ ERROR mismatched types | |
156 | //~| expected `u8` | |
157 | //~| found `u16` | |
85aaf69f SL |
158 | id_u8(b32); |
159 | //~^ ERROR mismatched types | |
160 | //~| expected `u8` | |
161 | //~| found `u32` | |
85aaf69f SL |
162 | id_u8(b64); |
163 | //~^ ERROR mismatched types | |
164 | //~| expected `u8` | |
165 | //~| found `u64` | |
223e47cc | 166 | |
85aaf69f SL |
167 | id_u16(b8); |
168 | //~^ ERROR mismatched types | |
169 | //~| expected `u16` | |
170 | //~| found `u8` | |
223e47cc | 171 | id_u16(b16); // ok |
85aaf69f SL |
172 | id_u16(b32); |
173 | //~^ ERROR mismatched types | |
174 | //~| expected `u16` | |
175 | //~| found `u32` | |
85aaf69f SL |
176 | id_u16(b64); |
177 | //~^ ERROR mismatched types | |
178 | //~| expected `u16` | |
179 | //~| found `u64` | |
223e47cc | 180 | |
85aaf69f SL |
181 | id_u32(b8); |
182 | //~^ ERROR mismatched types | |
183 | //~| expected `u32` | |
184 | //~| found `u8` | |
85aaf69f SL |
185 | id_u32(b16); |
186 | //~^ ERROR mismatched types | |
187 | //~| expected `u32` | |
188 | //~| found `u16` | |
223e47cc | 189 | id_u32(b32); // ok |
85aaf69f SL |
190 | id_u32(b64); |
191 | //~^ ERROR mismatched types | |
192 | //~| expected `u32` | |
193 | //~| found `u64` | |
223e47cc | 194 | |
85aaf69f SL |
195 | id_u64(b8); |
196 | //~^ ERROR mismatched types | |
197 | //~| expected `u64` | |
198 | //~| found `u8` | |
85aaf69f SL |
199 | id_u64(b16); |
200 | //~^ ERROR mismatched types | |
201 | //~| expected `u64` | |
202 | //~| found `u16` | |
85aaf69f SL |
203 | id_u64(b32); |
204 | //~^ ERROR mismatched types | |
205 | //~| expected `u64` | |
206 | //~| found `u32` | |
223e47cc LB |
207 | id_u64(b64); // ok |
208 | } |