3 // The `try_into` suggestion doesn't include this, but we do suggest it after applying it
4 use std::convert::TryInto;
9 let x_usize: usize = 1;
14 let x_isize: isize = 6;
19 let x_f64: f64 = 11.0;
20 let x_f32: f32 = 12.0;
22 foo::<usize>(x_usize);
23 foo::<usize>(x_u64.try_into().unwrap());
24 //~^ ERROR mismatched types
25 foo::<usize>(x_u32.try_into().unwrap());
26 //~^ ERROR mismatched types
27 foo::<usize>(x_u16.into());
28 //~^ ERROR mismatched types
29 foo::<usize>(x_u8.into());
30 //~^ ERROR mismatched types
31 foo::<usize>(x_isize.try_into().unwrap());
32 //~^ ERROR mismatched types
33 foo::<usize>(x_i64.try_into().unwrap());
34 //~^ ERROR mismatched types
35 foo::<usize>(x_i32.try_into().unwrap());
36 //~^ ERROR mismatched types
37 foo::<usize>(x_i16.try_into().unwrap());
38 //~^ ERROR mismatched types
39 foo::<usize>(x_i8.try_into().unwrap());
40 //~^ ERROR mismatched types
41 // foo::<usize>(x_f64);
42 // foo::<usize>(x_f32);
44 foo::<isize>(x_usize.try_into().unwrap());
45 //~^ ERROR mismatched types
46 foo::<isize>(x_u64.try_into().unwrap());
47 //~^ ERROR mismatched types
48 foo::<isize>(x_u32.try_into().unwrap());
49 //~^ ERROR mismatched types
50 foo::<isize>(x_u16.try_into().unwrap());
51 //~^ ERROR mismatched types
52 foo::<isize>(x_u8.into());
53 //~^ ERROR mismatched types
54 foo::<isize>(x_isize);
55 foo::<isize>(x_i64.try_into().unwrap());
56 //~^ ERROR mismatched types
57 foo::<isize>(x_i32.try_into().unwrap());
58 //~^ ERROR mismatched types
59 foo::<isize>(x_i16.into());
60 //~^ ERROR mismatched types
61 foo::<isize>(x_i8.into());
62 //~^ ERROR mismatched types
63 // foo::<isize>(x_f64);
64 // foo::<isize>(x_f32);
66 foo::<u64>(x_usize.try_into().unwrap());
67 //~^ ERROR mismatched types
69 foo::<u64>(x_u32.into());
70 //~^ ERROR mismatched types
71 foo::<u64>(x_u16.into());
72 //~^ ERROR mismatched types
73 foo::<u64>(x_u8.into());
74 //~^ ERROR mismatched types
75 foo::<u64>(x_isize.try_into().unwrap());
76 //~^ ERROR mismatched types
77 foo::<u64>(x_i64.try_into().unwrap());
78 //~^ ERROR mismatched types
79 foo::<u64>(x_i32.try_into().unwrap());
80 //~^ ERROR mismatched types
81 foo::<u64>(x_i16.try_into().unwrap());
82 //~^ ERROR mismatched types
83 foo::<u64>(x_i8.try_into().unwrap());
84 //~^ ERROR mismatched types
88 foo::<i64>(x_usize.try_into().unwrap());
89 //~^ ERROR mismatched types
90 foo::<i64>(x_u64.try_into().unwrap());
91 //~^ ERROR mismatched types
92 foo::<i64>(x_u32.into());
93 //~^ ERROR mismatched types
94 foo::<i64>(x_u16.into());
95 //~^ ERROR mismatched types
96 foo::<i64>(x_u8.into());
97 //~^ ERROR mismatched types
98 foo::<i64>(x_isize.try_into().unwrap());
99 //~^ ERROR mismatched types
101 foo::<i64>(x_i32.into());
102 //~^ ERROR mismatched types
103 foo::<i64>(x_i16.into());
104 //~^ ERROR mismatched types
105 foo::<i64>(x_i8.into());
106 //~^ ERROR mismatched types
107 // foo::<i64>(x_f64);
108 // foo::<i64>(x_f32);
110 foo::<u32>(x_usize.try_into().unwrap());
111 //~^ ERROR mismatched types
112 foo::<u32>(x_u64.try_into().unwrap());
113 //~^ ERROR mismatched types
115 foo::<u32>(x_u16.into());
116 //~^ ERROR mismatched types
117 foo::<u32>(x_u8.into());
118 //~^ ERROR mismatched types
119 foo::<u32>(x_isize.try_into().unwrap());
120 //~^ ERROR mismatched types
121 foo::<u32>(x_i64.try_into().unwrap());
122 //~^ ERROR mismatched types
123 foo::<u32>(x_i32.try_into().unwrap());
124 //~^ ERROR mismatched types
125 foo::<u32>(x_i16.try_into().unwrap());
126 //~^ ERROR mismatched types
127 foo::<u32>(x_i8.try_into().unwrap());
128 //~^ ERROR mismatched types
129 // foo::<u32>(x_f64);
130 // foo::<u32>(x_f32);
132 foo::<i32>(x_usize.try_into().unwrap());
133 //~^ ERROR mismatched types
134 foo::<i32>(x_u64.try_into().unwrap());
135 //~^ ERROR mismatched types
136 foo::<i32>(x_u32.try_into().unwrap());
137 //~^ ERROR mismatched types
138 foo::<i32>(x_u16.into());
139 //~^ ERROR mismatched types
140 foo::<i32>(x_u8.into());
141 //~^ ERROR mismatched types
142 foo::<i32>(x_isize.try_into().unwrap());
143 //~^ ERROR mismatched types
144 foo::<i32>(x_i64.try_into().unwrap());
145 //~^ ERROR mismatched types
147 foo::<i32>(x_i16.into());
148 //~^ ERROR mismatched types
149 foo::<i32>(x_i8.into());
150 //~^ ERROR mismatched types
151 // foo::<i32>(x_f64);
152 // foo::<i32>(x_f32);
154 foo::<u16>(x_usize.try_into().unwrap());
155 //~^ ERROR mismatched types
156 foo::<u16>(x_u64.try_into().unwrap());
157 //~^ ERROR mismatched types
158 foo::<u16>(x_u32.try_into().unwrap());
159 //~^ ERROR mismatched types
161 foo::<u16>(x_u8.into());
162 //~^ ERROR mismatched types
163 foo::<u16>(x_isize.try_into().unwrap());
164 //~^ ERROR mismatched types
165 foo::<u16>(x_i64.try_into().unwrap());
166 //~^ ERROR mismatched types
167 foo::<u16>(x_i32.try_into().unwrap());
168 //~^ ERROR mismatched types
169 foo::<u16>(x_i16.try_into().unwrap());
170 //~^ ERROR mismatched types
171 foo::<u16>(x_i8.try_into().unwrap());
172 //~^ ERROR mismatched types
173 // foo::<u16>(x_f64);
174 // foo::<u16>(x_f32);
176 foo::<i16>(x_usize.try_into().unwrap());
177 //~^ ERROR mismatched types
178 foo::<i16>(x_u64.try_into().unwrap());
179 //~^ ERROR mismatched types
180 foo::<i16>(x_u32.try_into().unwrap());
181 //~^ ERROR mismatched types
182 foo::<i16>(x_u16.try_into().unwrap());
183 //~^ ERROR mismatched types
184 foo::<i16>(x_u8.into());
185 //~^ ERROR mismatched types
186 foo::<i16>(x_isize.try_into().unwrap());
187 //~^ ERROR mismatched types
188 foo::<i16>(x_i64.try_into().unwrap());
189 //~^ ERROR mismatched types
190 foo::<i16>(x_i32.try_into().unwrap());
191 //~^ ERROR mismatched types
193 foo::<i16>(x_i8.into());
194 //~^ ERROR mismatched types
195 // foo::<i16>(x_f64);
196 // foo::<i16>(x_f32);
198 foo::<u8>(x_usize.try_into().unwrap());
199 //~^ ERROR mismatched types
200 foo::<u8>(x_u64.try_into().unwrap());
201 //~^ ERROR mismatched types
202 foo::<u8>(x_u32.try_into().unwrap());
203 //~^ ERROR mismatched types
204 foo::<u8>(x_u16.try_into().unwrap());
205 //~^ ERROR mismatched types
207 foo::<u8>(x_isize.try_into().unwrap());
208 //~^ ERROR mismatched types
209 foo::<u8>(x_i64.try_into().unwrap());
210 //~^ ERROR mismatched types
211 foo::<u8>(x_i32.try_into().unwrap());
212 //~^ ERROR mismatched types
213 foo::<u8>(x_i16.try_into().unwrap());
214 //~^ ERROR mismatched types
215 foo::<u8>(x_i8.try_into().unwrap());
216 //~^ ERROR mismatched types
220 foo::<i8>(x_usize.try_into().unwrap());
221 //~^ ERROR mismatched types
222 foo::<i8>(x_u64.try_into().unwrap());
223 //~^ ERROR mismatched types
224 foo::<i8>(x_u32.try_into().unwrap());
225 //~^ ERROR mismatched types
226 foo::<i8>(x_u16.try_into().unwrap());
227 //~^ ERROR mismatched types
228 foo::<i8>(x_u8.try_into().unwrap());
229 //~^ ERROR mismatched types
230 foo::<i8>(x_isize.try_into().unwrap());
231 //~^ ERROR mismatched types
232 foo::<i8>(x_i64.try_into().unwrap());
233 //~^ ERROR mismatched types
234 foo::<i8>(x_i32.try_into().unwrap());
235 //~^ ERROR mismatched types
236 foo::<i8>(x_i16.try_into().unwrap());
237 //~^ ERROR mismatched types
242 foo::<f64>(x_usize as f64);
243 //~^ ERROR mismatched types
244 foo::<f64>(x_u64 as f64);
245 //~^ ERROR mismatched types
246 foo::<f64>(x_u32.into());
247 //~^ ERROR mismatched types
248 foo::<f64>(x_u16.into());
249 //~^ ERROR mismatched types
250 foo::<f64>(x_u8.into());
251 //~^ ERROR mismatched types
252 foo::<f64>(x_isize as f64);
253 //~^ ERROR mismatched types
254 foo::<f64>(x_i64 as f64);
255 //~^ ERROR mismatched types
256 foo::<f64>(x_i32.into());
257 //~^ ERROR mismatched types
258 foo::<f64>(x_i16.into());
259 //~^ ERROR mismatched types
260 foo::<f64>(x_i8.into());
261 //~^ ERROR mismatched types
263 foo::<f64>(x_f32.into());
264 //~^ ERROR mismatched types
266 foo::<f32>(x_usize as f32);
267 //~^ ERROR mismatched types
268 foo::<f32>(x_u64 as f32);
269 //~^ ERROR mismatched types
270 foo::<f32>(x_u32 as f32);
271 //~^ ERROR mismatched types
272 foo::<f32>(x_u16.into());
273 //~^ ERROR mismatched types
274 foo::<f32>(x_u8.into());
275 //~^ ERROR mismatched types
276 foo::<f32>(x_isize as f32);
277 //~^ ERROR mismatched types
278 foo::<f32>(x_i64 as f32);
279 //~^ ERROR mismatched types
280 foo::<f32>(x_i32 as f32);
281 //~^ ERROR mismatched types
282 foo::<f32>(x_i16.into());
283 //~^ ERROR mismatched types
284 foo::<f32>(x_i8.into());
285 //~^ ERROR mismatched types
286 // foo::<f32>(x_f64);
289 foo::<u32>((x_u8 as u16).into());
290 //~^ ERROR mismatched types
291 foo::<i32>((-x_i8).into());
292 //~^ ERROR mismatched types