diff options
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 2432 |
1 files changed, 1265 insertions, 1167 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index e3eb0c3fa..b034fd59e 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -1,7 +1,7 @@ | |||
1 | use std::fmt::Write; | 1 | use std::fmt::Write; |
2 | use std::sync::Arc; | 2 | use std::sync::Arc; |
3 | 3 | ||
4 | use insta::assert_snapshot_matches; | 4 | use insta::assert_snapshot; |
5 | 5 | ||
6 | use ra_db::{salsa::Database, FilePosition, SourceDatabase}; | 6 | use ra_db::{salsa::Database, FilePosition, SourceDatabase}; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
@@ -166,7 +166,7 @@ fn test() { | |||
166 | 166 | ||
167 | #[test] | 167 | #[test] |
168 | fn infer_basics() { | 168 | fn infer_basics() { |
169 | assert_snapshot_matches!( | 169 | assert_snapshot!( |
170 | infer(r#" | 170 | infer(r#" |
171 | fn test(a: u32, b: isize, c: !, d: &str) { | 171 | fn test(a: u32, b: isize, c: !, d: &str) { |
172 | a; | 172 | a; |
@@ -179,25 +179,27 @@ fn test(a: u32, b: isize, c: !, d: &str) { | |||
179 | 1.0f32; | 179 | 1.0f32; |
180 | }"#), | 180 | }"#), |
181 | @r###" | 181 | @r###" |
182 | [9; 10) 'a': u32 | 182 | |
183 | [17; 18) 'b': isize | 183 | [9; 10) 'a': u32 |
184 | [27; 28) 'c': ! | 184 | [17; 18) 'b': isize |
185 | [33; 34) 'd': &str | 185 | [27; 28) 'c': ! |
186 | [42; 121) '{ ...f32; }': () | 186 | [33; 34) 'd': &str |
187 | [48; 49) 'a': u32 | 187 | [42; 121) '{ ...f32; }': () |
188 | [55; 56) 'b': isize | 188 | [48; 49) 'a': u32 |
189 | [62; 63) 'c': ! | 189 | [55; 56) 'b': isize |
190 | [69; 70) 'd': &str | 190 | [62; 63) 'c': ! |
191 | [76; 82) '1usize': usize | 191 | [69; 70) 'd': &str |
192 | [88; 94) '1isize': isize | 192 | [76; 82) '1usize': usize |
193 | [100; 106) '"test"': &str | 193 | [88; 94) '1isize': isize |
194 | [112; 118) '1.0f32': f32"### | 194 | [100; 106) '"test"': &str |
195 | [112; 118) '1.0f32': f32 | ||
196 | "### | ||
195 | ); | 197 | ); |
196 | } | 198 | } |
197 | 199 | ||
198 | #[test] | 200 | #[test] |
199 | fn infer_let() { | 201 | fn infer_let() { |
200 | assert_snapshot_matches!( | 202 | assert_snapshot!( |
201 | infer(r#" | 203 | infer(r#" |
202 | fn test() { | 204 | fn test() { |
203 | let a = 1isize; | 205 | let a = 1isize; |
@@ -206,19 +208,21 @@ fn test() { | |||
206 | } | 208 | } |
207 | "#), | 209 | "#), |
208 | @r###" | 210 | @r###" |
209 | [11; 71) '{ ...= b; }': () | 211 | |
210 | [21; 22) 'a': isize | 212 | [11; 71) '{ ...= b; }': () |
211 | [25; 31) '1isize': isize | 213 | [21; 22) 'a': isize |
212 | [41; 42) 'b': usize | 214 | [25; 31) '1isize': isize |
213 | [52; 53) '1': usize | 215 | [41; 42) 'b': usize |
214 | [63; 64) 'c': usize | 216 | [52; 53) '1': usize |
215 | [67; 68) 'b': usize"### | 217 | [63; 64) 'c': usize |
218 | [67; 68) 'b': usize | ||
219 | "### | ||
216 | ); | 220 | ); |
217 | } | 221 | } |
218 | 222 | ||
219 | #[test] | 223 | #[test] |
220 | fn infer_paths() { | 224 | fn infer_paths() { |
221 | assert_snapshot_matches!( | 225 | assert_snapshot!( |
222 | infer(r#" | 226 | infer(r#" |
223 | fn a() -> u32 { 1 } | 227 | fn a() -> u32 { 1 } |
224 | 228 | ||
@@ -232,21 +236,23 @@ fn test() { | |||
232 | } | 236 | } |
233 | "#), | 237 | "#), |
234 | @r###" | 238 | @r###" |
235 | [15; 20) '{ 1 }': u32 | 239 | |
236 | [17; 18) '1': u32 | 240 | [15; 20) '{ 1 }': u32 |
237 | [48; 53) '{ 1 }': u32 | 241 | [17; 18) '1': u32 |
238 | [50; 51) '1': u32 | 242 | [48; 53) '{ 1 }': u32 |
239 | [67; 91) '{ ...c(); }': () | 243 | [50; 51) '1': u32 |
240 | [73; 74) 'a': fn a() -> u32 | 244 | [67; 91) '{ ...c(); }': () |
241 | [73; 76) 'a()': u32 | 245 | [73; 74) 'a': fn a() -> u32 |
242 | [82; 86) 'b::c': fn c() -> u32 | 246 | [73; 76) 'a()': u32 |
243 | [82; 88) 'b::c()': u32"### | 247 | [82; 86) 'b::c': fn c() -> u32 |
248 | [82; 88) 'b::c()': u32 | ||
249 | "### | ||
244 | ); | 250 | ); |
245 | } | 251 | } |
246 | 252 | ||
247 | #[test] | 253 | #[test] |
248 | fn infer_struct() { | 254 | fn infer_struct() { |
249 | assert_snapshot_matches!( | 255 | assert_snapshot!( |
250 | infer(r#" | 256 | infer(r#" |
251 | struct A { | 257 | struct A { |
252 | b: B, | 258 | b: B, |
@@ -264,28 +270,30 @@ fn test() { | |||
264 | } | 270 | } |
265 | "#), | 271 | "#), |
266 | @r###" | 272 | @r###" |
267 | [72; 154) '{ ...a.c; }': () | 273 | |
268 | [82; 83) 'c': C | 274 | [72; 154) '{ ...a.c; }': () |
269 | [86; 87) 'C': C(usize) -> C | 275 | [82; 83) 'c': C |
270 | [86; 90) 'C(1)': C | 276 | [86; 87) 'C': C(usize) -> C |
271 | [88; 89) '1': usize | 277 | [86; 90) 'C(1)': C |
272 | [96; 97) 'B': B | 278 | [88; 89) '1': usize |
273 | [107; 108) 'a': A | 279 | [96; 97) 'B': B |
274 | [114; 133) 'A { b:...C(1) }': A | 280 | [107; 108) 'a': A |
275 | [121; 122) 'B': B | 281 | [114; 133) 'A { b:...C(1) }': A |
276 | [127; 128) 'C': C(usize) -> C | 282 | [121; 122) 'B': B |
277 | [127; 131) 'C(1)': C | 283 | [127; 128) 'C': C(usize) -> C |
278 | [129; 130) '1': usize | 284 | [127; 131) 'C(1)': C |
279 | [139; 140) 'a': A | 285 | [129; 130) '1': usize |
280 | [139; 142) 'a.b': B | 286 | [139; 140) 'a': A |
281 | [148; 149) 'a': A | 287 | [139; 142) 'a.b': B |
282 | [148; 151) 'a.c': C"### | 288 | [148; 149) 'a': A |
289 | [148; 151) 'a.c': C | ||
290 | "### | ||
283 | ); | 291 | ); |
284 | } | 292 | } |
285 | 293 | ||
286 | #[test] | 294 | #[test] |
287 | fn infer_enum() { | 295 | fn infer_enum() { |
288 | assert_snapshot_matches!( | 296 | assert_snapshot!( |
289 | infer(r#" | 297 | infer(r#" |
290 | enum E { | 298 | enum E { |
291 | V1 { field: u32 }, | 299 | V1 { field: u32 }, |
@@ -296,16 +304,18 @@ fn test() { | |||
296 | E::V2; | 304 | E::V2; |
297 | }"#), | 305 | }"#), |
298 | @r###" | 306 | @r###" |
299 | [48; 82) '{ E:...:V2; }': () | 307 | |
300 | [52; 70) 'E::V1 ...d: 1 }': E | 308 | [48; 82) '{ E:...:V2; }': () |
301 | [67; 68) '1': u32 | 309 | [52; 70) 'E::V1 ...d: 1 }': E |
302 | [74; 79) 'E::V2': E"### | 310 | [67; 68) '1': u32 |
311 | [74; 79) 'E::V2': E | ||
312 | "### | ||
303 | ); | 313 | ); |
304 | } | 314 | } |
305 | 315 | ||
306 | #[test] | 316 | #[test] |
307 | fn infer_refs() { | 317 | fn infer_refs() { |
308 | assert_snapshot_matches!( | 318 | assert_snapshot!( |
309 | infer(r#" | 319 | infer(r#" |
310 | fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { | 320 | fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { |
311 | a; | 321 | a; |
@@ -322,35 +332,37 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { | |||
322 | } | 332 | } |
323 | "#), | 333 | "#), |
324 | @r###" | 334 | @r###" |
325 | [9; 10) 'a': &u32 | 335 | |
326 | [18; 19) 'b': &mut u32 | 336 | [9; 10) 'a': &u32 |
327 | [31; 32) 'c': *const u32 | 337 | [18; 19) 'b': &mut u32 |
328 | [46; 47) 'd': *mut u32 | 338 | [31; 32) 'c': *const u32 |
329 | [59; 150) '{ ... *d; }': () | 339 | [46; 47) 'd': *mut u32 |
330 | [65; 66) 'a': &u32 | 340 | [59; 150) '{ ... *d; }': () |
331 | [72; 74) '*a': u32 | 341 | [65; 66) 'a': &u32 |
332 | [73; 74) 'a': &u32 | 342 | [72; 74) '*a': u32 |
333 | [80; 82) '&a': &&u32 | 343 | [73; 74) 'a': &u32 |
334 | [81; 82) 'a': &u32 | 344 | [80; 82) '&a': &&u32 |
335 | [88; 94) '&mut a': &mut &u32 | 345 | [81; 82) 'a': &u32 |
336 | [93; 94) 'a': &u32 | 346 | [88; 94) '&mut a': &mut &u32 |
337 | [100; 101) 'b': &mut u32 | 347 | [93; 94) 'a': &u32 |
338 | [107; 109) '*b': u32 | 348 | [100; 101) 'b': &mut u32 |
339 | [108; 109) 'b': &mut u32 | 349 | [107; 109) '*b': u32 |
340 | [115; 117) '&b': &&mut u32 | 350 | [108; 109) 'b': &mut u32 |
341 | [116; 117) 'b': &mut u32 | 351 | [115; 117) '&b': &&mut u32 |
342 | [123; 124) 'c': *const u32 | 352 | [116; 117) 'b': &mut u32 |
343 | [130; 132) '*c': u32 | 353 | [123; 124) 'c': *const u32 |
344 | [131; 132) 'c': *const u32 | 354 | [130; 132) '*c': u32 |
345 | [138; 139) 'd': *mut u32 | 355 | [131; 132) 'c': *const u32 |
346 | [145; 147) '*d': u32 | 356 | [138; 139) 'd': *mut u32 |
347 | [146; 147) 'd': *mut u32"### | 357 | [145; 147) '*d': u32 |
358 | [146; 147) 'd': *mut u32 | ||
359 | "### | ||
348 | ); | 360 | ); |
349 | } | 361 | } |
350 | 362 | ||
351 | #[test] | 363 | #[test] |
352 | fn infer_literals() { | 364 | fn infer_literals() { |
353 | assert_snapshot_matches!( | 365 | assert_snapshot!( |
354 | infer(r##" | 366 | infer(r##" |
355 | fn test() { | 367 | fn test() { |
356 | 5i32; | 368 | 5i32; |
@@ -373,26 +385,28 @@ fn test() { | |||
373 | } | 385 | } |
374 | "##), | 386 | "##), |
375 | @r###" | 387 | @r###" |
376 | [11; 221) '{ ...o"#; }': () | 388 | |
377 | [17; 21) '5i32': i32 | 389 | [11; 221) '{ ...o"#; }': () |
378 | [27; 31) '5f32': f32 | 390 | [17; 21) '5i32': i32 |
379 | [37; 41) '5f64': f64 | 391 | [27; 31) '5f32': f32 |
380 | [47; 54) '"hello"': &str | 392 | [37; 41) '5f64': f64 |
381 | [60; 68) 'b"bytes"': &[u8] | 393 | [47; 54) '"hello"': &str |
382 | [74; 77) ''c'': char | 394 | [60; 68) 'b"bytes"': &[u8] |
383 | [83; 87) 'b'b'': u8 | 395 | [74; 77) ''c'': char |
384 | [93; 97) '3.14': f64 | 396 | [83; 87) 'b'b'': u8 |
385 | [103; 107) '5000': i32 | 397 | [93; 97) '3.14': f64 |
386 | [113; 118) 'false': bool | 398 | [103; 107) '5000': i32 |
387 | [124; 128) 'true': bool | 399 | [113; 118) 'false': bool |
388 | [134; 202) 'r#" ... "#': &str | 400 | [124; 128) 'true': bool |
389 | [208; 218) 'br#"yolo"#': &[u8]"### | 401 | [134; 202) 'r#" ... "#': &str |
402 | [208; 218) 'br#"yolo"#': &[u8] | ||
403 | "### | ||
390 | ); | 404 | ); |
391 | } | 405 | } |
392 | 406 | ||
393 | #[test] | 407 | #[test] |
394 | fn infer_unary_op() { | 408 | fn infer_unary_op() { |
395 | assert_snapshot_matches!( | 409 | assert_snapshot!( |
396 | infer(r#" | 410 | infer(r#" |
397 | enum SomeType {} | 411 | enum SomeType {} |
398 | 412 | ||
@@ -415,53 +429,55 @@ fn test(x: SomeType) { | |||
415 | } | 429 | } |
416 | "#), | 430 | "#), |
417 | @r###" | 431 | @r###" |
418 | [27; 28) 'x': SomeType | 432 | |
419 | [40; 272) '{ ...lo"; }': () | 433 | [27; 28) 'x': SomeType |
420 | [50; 51) 'b': bool | 434 | [40; 272) '{ ...lo"; }': () |
421 | [54; 59) 'false': bool | 435 | [50; 51) 'b': bool |
422 | [69; 70) 'c': bool | 436 | [54; 59) 'false': bool |
423 | [73; 75) '!b': bool | 437 | [69; 70) 'c': bool |
424 | [74; 75) 'b': bool | 438 | [73; 75) '!b': bool |
425 | [85; 86) 'a': i128 | 439 | [74; 75) 'b': bool |
426 | [89; 92) '100': i128 | 440 | [85; 86) 'a': i128 |
427 | [102; 103) 'd': i128 | 441 | [89; 92) '100': i128 |
428 | [112; 114) '-a': i128 | 442 | [102; 103) 'd': i128 |
429 | [113; 114) 'a': i128 | 443 | [112; 114) '-a': i128 |
430 | [124; 125) 'e': i32 | 444 | [113; 114) 'a': i128 |
431 | [128; 132) '-100': i32 | 445 | [124; 125) 'e': i32 |
432 | [129; 132) '100': i32 | 446 | [128; 132) '-100': i32 |
433 | [142; 143) 'f': bool | 447 | [129; 132) '100': i32 |
434 | [146; 153) '!!!true': bool | 448 | [142; 143) 'f': bool |
435 | [147; 153) '!!true': bool | 449 | [146; 153) '!!!true': bool |
436 | [148; 153) '!true': bool | 450 | [147; 153) '!!true': bool |
437 | [149; 153) 'true': bool | 451 | [148; 153) '!true': bool |
438 | [163; 164) 'g': i32 | 452 | [149; 153) 'true': bool |
439 | [167; 170) '!42': i32 | 453 | [163; 164) 'g': i32 |
440 | [168; 170) '42': i32 | 454 | [167; 170) '!42': i32 |
441 | [180; 181) 'h': u32 | 455 | [168; 170) '42': i32 |
442 | [184; 190) '!10u32': u32 | 456 | [180; 181) 'h': u32 |
443 | [185; 190) '10u32': u32 | 457 | [184; 190) '!10u32': u32 |
444 | [200; 201) 'j': i128 | 458 | [185; 190) '10u32': u32 |
445 | [204; 206) '!a': i128 | 459 | [200; 201) 'j': i128 |
446 | [205; 206) 'a': i128 | 460 | [204; 206) '!a': i128 |
447 | [212; 217) '-3.14': f64 | 461 | [205; 206) 'a': i128 |
448 | [213; 217) '3.14': f64 | 462 | [212; 217) '-3.14': f64 |
449 | [223; 225) '!3': i32 | 463 | [213; 217) '3.14': f64 |
450 | [224; 225) '3': i32 | 464 | [223; 225) '!3': i32 |
451 | [231; 233) '-x': {unknown} | 465 | [224; 225) '3': i32 |
452 | [232; 233) 'x': SomeType | 466 | [231; 233) '-x': {unknown} |
453 | [239; 241) '!x': {unknown} | 467 | [232; 233) 'x': SomeType |
454 | [240; 241) 'x': SomeType | 468 | [239; 241) '!x': {unknown} |
455 | [247; 255) '-"hello"': {unknown} | 469 | [240; 241) 'x': SomeType |
456 | [248; 255) '"hello"': &str | 470 | [247; 255) '-"hello"': {unknown} |
457 | [261; 269) '!"hello"': {unknown} | 471 | [248; 255) '"hello"': &str |
458 | [262; 269) '"hello"': &str"### | 472 | [261; 269) '!"hello"': {unknown} |
473 | [262; 269) '"hello"': &str | ||
474 | "### | ||
459 | ); | 475 | ); |
460 | } | 476 | } |
461 | 477 | ||
462 | #[test] | 478 | #[test] |
463 | fn infer_backwards() { | 479 | fn infer_backwards() { |
464 | assert_snapshot_matches!( | 480 | assert_snapshot!( |
465 | infer(r#" | 481 | infer(r#" |
466 | fn takes_u32(x: u32) {} | 482 | fn takes_u32(x: u32) {} |
467 | 483 | ||
@@ -477,32 +493,34 @@ fn test() -> &mut &f64 { | |||
477 | } | 493 | } |
478 | "#), | 494 | "#), |
479 | @r###" | 495 | @r###" |
480 | [14; 15) 'x': u32 | 496 | |
481 | [22; 24) '{}': () | 497 | [14; 15) 'x': u32 |
482 | [78; 231) '{ ...t &c }': &mut &f64 | 498 | [22; 24) '{}': () |
483 | [88; 89) 'a': u32 | 499 | [78; 231) '{ ...t &c }': &mut &f64 |
484 | [92; 108) 'unknow...nction': {unknown} | 500 | [88; 89) 'a': u32 |
485 | [92; 110) 'unknow...tion()': u32 | 501 | [92; 108) 'unknow...nction': {unknown} |
486 | [116; 125) 'takes_u32': fn takes_u32(u32) -> () | 502 | [92; 110) 'unknow...tion()': u32 |
487 | [116; 128) 'takes_u32(a)': () | 503 | [116; 125) 'takes_u32': fn takes_u32(u32) -> () |
488 | [126; 127) 'a': u32 | 504 | [116; 128) 'takes_u32(a)': () |
489 | [138; 139) 'b': i32 | 505 | [126; 127) 'a': u32 |
490 | [142; 158) 'unknow...nction': {unknown} | 506 | [138; 139) 'b': i32 |
491 | [142; 160) 'unknow...tion()': i32 | 507 | [142; 158) 'unknow...nction': {unknown} |
492 | [166; 184) 'S { i3...d: b }': S | 508 | [142; 160) 'unknow...tion()': i32 |
493 | [181; 182) 'b': i32 | 509 | [166; 184) 'S { i3...d: b }': S |
494 | [194; 195) 'c': f64 | 510 | [181; 182) 'b': i32 |
495 | [198; 214) 'unknow...nction': {unknown} | 511 | [194; 195) 'c': f64 |
496 | [198; 216) 'unknow...tion()': f64 | 512 | [198; 214) 'unknow...nction': {unknown} |
497 | [222; 229) '&mut &c': &mut &f64 | 513 | [198; 216) 'unknow...tion()': f64 |
498 | [227; 229) '&c': &f64 | 514 | [222; 229) '&mut &c': &mut &f64 |
499 | [228; 229) 'c': f64"### | 515 | [227; 229) '&c': &f64 |
516 | [228; 229) 'c': f64 | ||
517 | "### | ||
500 | ); | 518 | ); |
501 | } | 519 | } |
502 | 520 | ||
503 | #[test] | 521 | #[test] |
504 | fn infer_self() { | 522 | fn infer_self() { |
505 | assert_snapshot_matches!( | 523 | assert_snapshot!( |
506 | infer(r#" | 524 | infer(r#" |
507 | struct S; | 525 | struct S; |
508 | 526 | ||
@@ -522,22 +540,24 @@ impl S { | |||
522 | } | 540 | } |
523 | "#), | 541 | "#), |
524 | @r###" | 542 | @r###" |
525 | [34; 38) 'self': &S | 543 | |
526 | [40; 61) '{ ... }': () | 544 | [34; 38) 'self': &S |
527 | [50; 54) 'self': &S | 545 | [40; 61) '{ ... }': () |
528 | [75; 79) 'self': &S | 546 | [50; 54) 'self': &S |
529 | [88; 109) '{ ... }': () | 547 | [75; 79) 'self': &S |
530 | [98; 102) 'self': &S | 548 | [88; 109) '{ ... }': () |
531 | [133; 153) '{ ... }': S | 549 | [98; 102) 'self': &S |
532 | [143; 147) 'S {}': S | 550 | [133; 153) '{ ... }': S |
533 | [177; 200) '{ ... }': S | 551 | [143; 147) 'S {}': S |
534 | [187; 194) 'Self {}': S"### | 552 | [177; 200) '{ ... }': S |
553 | [187; 194) 'Self {}': S | ||
554 | "### | ||
535 | ); | 555 | ); |
536 | } | 556 | } |
537 | 557 | ||
538 | #[test] | 558 | #[test] |
539 | fn infer_binary_op() { | 559 | fn infer_binary_op() { |
540 | assert_snapshot_matches!( | 560 | assert_snapshot!( |
541 | infer(r#" | 561 | infer(r#" |
542 | fn f(x: bool) -> i32 { | 562 | fn f(x: bool) -> i32 { |
543 | 0i32 | 563 | 0i32 |
@@ -560,62 +580,64 @@ fn test() -> bool { | |||
560 | } | 580 | } |
561 | "#), | 581 | "#), |
562 | @r###" | 582 | @r###" |
563 | [6; 7) 'x': bool | 583 | |
564 | [22; 34) '{ 0i32 }': i32 | 584 | [6; 7) 'x': bool |
565 | [28; 32) '0i32': i32 | 585 | [22; 34) '{ 0i32 }': i32 |
566 | [54; 370) '{ ... < 3 }': bool | 586 | [28; 32) '0i32': i32 |
567 | [64; 65) 'x': bool | 587 | [54; 370) '{ ... < 3 }': bool |
568 | [68; 69) 'a': bool | 588 | [64; 65) 'x': bool |
569 | [68; 74) 'a && b': bool | 589 | [68; 69) 'a': bool |
570 | [73; 74) 'b': bool | 590 | [68; 74) 'a && b': bool |
571 | [84; 85) 'y': bool | 591 | [73; 74) 'b': bool |
572 | [88; 92) 'true': bool | 592 | [84; 85) 'y': bool |
573 | [88; 101) 'true || false': bool | 593 | [88; 92) 'true': bool |
574 | [96; 101) 'false': bool | 594 | [88; 101) 'true || false': bool |
575 | [111; 112) 'z': bool | 595 | [96; 101) 'false': bool |
576 | [115; 116) 'x': bool | 596 | [111; 112) 'z': bool |
577 | [115; 121) 'x == y': bool | 597 | [115; 116) 'x': bool |
578 | [120; 121) 'y': bool | 598 | [115; 121) 'x == y': bool |
579 | [131; 132) 't': bool | 599 | [120; 121) 'y': bool |
580 | [135; 136) 'x': bool | 600 | [131; 132) 't': bool |
581 | [135; 141) 'x != y': bool | 601 | [135; 136) 'x': bool |
582 | [140; 141) 'y': bool | 602 | [135; 141) 'x != y': bool |
583 | [151; 162) 'minus_forty': isize | 603 | [140; 141) 'y': bool |
584 | [172; 180) '-40isize': isize | 604 | [151; 162) 'minus_forty': isize |
585 | [173; 180) '40isize': isize | 605 | [172; 180) '-40isize': isize |
586 | [190; 191) 'h': bool | 606 | [173; 180) '40isize': isize |
587 | [194; 205) 'minus_forty': isize | 607 | [190; 191) 'h': bool |
588 | [194; 216) 'minus_...ONST_2': bool | 608 | [194; 205) 'minus_forty': isize |
589 | [209; 216) 'CONST_2': isize | 609 | [194; 216) 'minus_...ONST_2': bool |
590 | [226; 227) 'c': i32 | 610 | [209; 216) 'CONST_2': isize |
591 | [230; 231) 'f': fn f(bool) -> i32 | 611 | [226; 227) 'c': i32 |
592 | [230; 239) 'f(z || y)': i32 | 612 | [230; 231) 'f': fn f(bool) -> i32 |
593 | [230; 243) 'f(z || y) + 5': i32 | 613 | [230; 239) 'f(z || y)': i32 |
594 | [232; 233) 'z': bool | 614 | [230; 243) 'f(z || y) + 5': i32 |
595 | [232; 238) 'z || y': bool | 615 | [232; 233) 'z': bool |
596 | [237; 238) 'y': bool | 616 | [232; 238) 'z || y': bool |
597 | [242; 243) '5': i32 | 617 | [237; 238) 'y': bool |
598 | [253; 254) 'd': {unknown} | 618 | [242; 243) '5': i32 |
599 | [257; 258) 'b': {unknown} | 619 | [253; 254) 'd': {unknown} |
600 | [268; 269) 'g': () | 620 | [257; 258) 'b': {unknown} |
601 | [272; 283) 'minus_forty': isize | 621 | [268; 269) 'g': () |
602 | [272; 288) 'minus_...y ^= i': () | 622 | [272; 283) 'minus_forty': isize |
603 | [287; 288) 'i': isize | 623 | [272; 288) 'minus_...y ^= i': () |
604 | [298; 301) 'ten': usize | 624 | [287; 288) 'i': isize |
605 | [311; 313) '10': usize | 625 | [298; 301) 'ten': usize |
606 | [323; 336) 'ten_is_eleven': bool | 626 | [311; 313) '10': usize |
607 | [339; 342) 'ten': usize | 627 | [323; 336) 'ten_is_eleven': bool |
608 | [339; 354) 'ten == some_num': bool | 628 | [339; 342) 'ten': usize |
609 | [346; 354) 'some_num': usize | 629 | [339; 354) 'ten == some_num': bool |
610 | [361; 364) 'ten': usize | 630 | [346; 354) 'some_num': usize |
611 | [361; 368) 'ten < 3': bool | 631 | [361; 364) 'ten': usize |
612 | [367; 368) '3': usize"### | 632 | [361; 368) 'ten < 3': bool |
633 | [367; 368) '3': usize | ||
634 | "### | ||
613 | ); | 635 | ); |
614 | } | 636 | } |
615 | 637 | ||
616 | #[test] | 638 | #[test] |
617 | fn infer_field_autoderef() { | 639 | fn infer_field_autoderef() { |
618 | assert_snapshot_matches!( | 640 | assert_snapshot!( |
619 | infer(r#" | 641 | infer(r#" |
620 | struct A { | 642 | struct A { |
621 | b: B, | 643 | b: B, |
@@ -641,72 +663,76 @@ fn test2(a1: *const A, a2: *mut A) { | |||
641 | } | 663 | } |
642 | "#), | 664 | "#), |
643 | @r###" | 665 | @r###" |
644 | [44; 45) 'a': A | 666 | |
645 | [50; 213) '{ ...5.b; }': () | 667 | [44; 45) 'a': A |
646 | [60; 62) 'a1': A | 668 | [50; 213) '{ ...5.b; }': () |
647 | [65; 66) 'a': A | 669 | [60; 62) 'a1': A |
648 | [72; 74) 'a1': A | 670 | [65; 66) 'a': A |
649 | [72; 76) 'a1.b': B | 671 | [72; 74) 'a1': A |
650 | [86; 88) 'a2': &A | 672 | [72; 76) 'a1.b': B |
651 | [91; 93) '&a': &A | 673 | [86; 88) 'a2': &A |
652 | [92; 93) 'a': A | 674 | [91; 93) '&a': &A |
653 | [99; 101) 'a2': &A | 675 | [92; 93) 'a': A |
654 | [99; 103) 'a2.b': B | 676 | [99; 101) 'a2': &A |
655 | [113; 115) 'a3': &mut A | 677 | [99; 103) 'a2.b': B |
656 | [118; 124) '&mut a': &mut A | 678 | [113; 115) 'a3': &mut A |
657 | [123; 124) 'a': A | 679 | [118; 124) '&mut a': &mut A |
658 | [130; 132) 'a3': &mut A | 680 | [123; 124) 'a': A |
659 | [130; 134) 'a3.b': B | 681 | [130; 132) 'a3': &mut A |
660 | [144; 146) 'a4': &&&&&&&A | 682 | [130; 134) 'a3.b': B |
661 | [149; 157) '&&&&&&&a': &&&&&&&A | 683 | [144; 146) 'a4': &&&&&&&A |
662 | [150; 157) '&&&&&&a': &&&&&&A | 684 | [149; 157) '&&&&&&&a': &&&&&&&A |
663 | [151; 157) '&&&&&a': &&&&&A | 685 | [150; 157) '&&&&&&a': &&&&&&A |
664 | [152; 157) '&&&&a': &&&&A | 686 | [151; 157) '&&&&&a': &&&&&A |
665 | [153; 157) '&&&a': &&&A | 687 | [152; 157) '&&&&a': &&&&A |
666 | [154; 157) '&&a': &&A | 688 | [153; 157) '&&&a': &&&A |
667 | [155; 157) '&a': &A | 689 | [154; 157) '&&a': &&A |
668 | [156; 157) 'a': A | 690 | [155; 157) '&a': &A |
669 | [163; 165) 'a4': &&&&&&&A | 691 | [156; 157) 'a': A |
670 | [163; 167) 'a4.b': B | 692 | [163; 165) 'a4': &&&&&&&A |
671 | [177; 179) 'a5': &mut &&mut &&mut A | 693 | [163; 167) 'a4.b': B |
672 | [182; 200) '&mut &...&mut a': &mut &&mut &&mut A | 694 | [177; 179) 'a5': &mut &&mut &&mut A |
673 | [187; 200) '&&mut &&mut a': &&mut &&mut A | 695 | [182; 200) '&mut &...&mut a': &mut &&mut &&mut A |
674 | [188; 200) '&mut &&mut a': &mut &&mut A | 696 | [187; 200) '&&mut &&mut a': &&mut &&mut A |
675 | [193; 200) '&&mut a': &&mut A | 697 | [188; 200) '&mut &&mut a': &mut &&mut A |
676 | [194; 200) '&mut a': &mut A | 698 | [193; 200) '&&mut a': &&mut A |
677 | [199; 200) 'a': A | 699 | [194; 200) '&mut a': &mut A |
678 | [206; 208) 'a5': &mut &&mut &&mut A | 700 | [199; 200) 'a': A |
679 | [206; 210) 'a5.b': B | 701 | [206; 208) 'a5': &mut &&mut &&mut A |
680 | [224; 226) 'a1': *const A | 702 | [206; 210) 'a5.b': B |
681 | [238; 240) 'a2': *mut A | 703 | [224; 226) 'a1': *const A |
682 | [250; 273) '{ ...2.b; }': () | 704 | [238; 240) 'a2': *mut A |
683 | [256; 258) 'a1': *const A | 705 | [250; 273) '{ ...2.b; }': () |
684 | [256; 260) 'a1.b': B | 706 | [256; 258) 'a1': *const A |
685 | [266; 268) 'a2': *mut A | 707 | [256; 260) 'a1.b': B |
686 | [266; 270) 'a2.b': B"### | 708 | [266; 268) 'a2': *mut A |
709 | [266; 270) 'a2.b': B | ||
710 | "### | ||
687 | ); | 711 | ); |
688 | } | 712 | } |
689 | 713 | ||
690 | #[test] | 714 | #[test] |
691 | fn bug_484() { | 715 | fn bug_484() { |
692 | assert_snapshot_matches!( | 716 | assert_snapshot!( |
693 | infer(r#" | 717 | infer(r#" |
694 | fn test() { | 718 | fn test() { |
695 | let x = if true {}; | 719 | let x = if true {}; |
696 | } | 720 | } |
697 | "#), | 721 | "#), |
698 | @r###" | 722 | @r###" |
699 | [11; 37) '{ l... {}; }': () | 723 | |
700 | [20; 21) 'x': () | 724 | [11; 37) '{ l... {}; }': () |
701 | [24; 34) 'if true {}': () | 725 | [20; 21) 'x': () |
702 | [27; 31) 'true': bool | 726 | [24; 34) 'if true {}': () |
703 | [32; 34) '{}': ()"### | 727 | [27; 31) 'true': bool |
728 | [32; 34) '{}': () | ||
729 | "### | ||
704 | ); | 730 | ); |
705 | } | 731 | } |
706 | 732 | ||
707 | #[test] | 733 | #[test] |
708 | fn infer_in_elseif() { | 734 | fn infer_in_elseif() { |
709 | assert_snapshot_matches!( | 735 | assert_snapshot!( |
710 | infer(r#" | 736 | infer(r#" |
711 | struct Foo { field: i32 } | 737 | struct Foo { field: i32 } |
712 | fn main(foo: Foo) { | 738 | fn main(foo: Foo) { |
@@ -718,24 +744,23 @@ fn main(foo: Foo) { | |||
718 | } | 744 | } |
719 | "#), | 745 | "#), |
720 | @r###" | 746 | @r###" |
721 | ⋮ | 747 | [35; 38) 'foo': Foo |
722 | ⋮[35; 38) 'foo': Foo | 748 | [45; 109) '{ ... } }': () |
723 | ⋮[45; 109) '{ ... } }': () | 749 | [51; 107) 'if tru... }': () |
724 | ⋮[51; 107) 'if tru... }': () | 750 | [54; 58) 'true': bool |
725 | ⋮[54; 58) 'true': bool | 751 | [59; 67) '{ }': () |
726 | ⋮[59; 67) '{ }': () | 752 | [73; 107) 'if fal... }': () |
727 | ⋮[73; 107) 'if fal... }': () | 753 | [76; 81) 'false': bool |
728 | ⋮[76; 81) 'false': bool | 754 | [82; 107) '{ ... }': i32 |
729 | ⋮[82; 107) '{ ... }': i32 | 755 | [92; 95) 'foo': Foo |
730 | ⋮[92; 95) 'foo': Foo | 756 | [92; 101) 'foo.field': i32 |
731 | ⋮[92; 101) 'foo.field': i32 | ||
732 | "### | 757 | "### |
733 | ) | 758 | ) |
734 | } | 759 | } |
735 | 760 | ||
736 | #[test] | 761 | #[test] |
737 | fn infer_inherent_method() { | 762 | fn infer_inherent_method() { |
738 | assert_snapshot_matches!( | 763 | assert_snapshot!( |
739 | infer(r#" | 764 | infer(r#" |
740 | struct A; | 765 | struct A; |
741 | 766 | ||
@@ -756,30 +781,32 @@ fn test(a: A) { | |||
756 | } | 781 | } |
757 | "#), | 782 | "#), |
758 | @r###" | 783 | @r###" |
759 | [32; 36) 'self': A | 784 | |
760 | [38; 39) 'x': u32 | 785 | [32; 36) 'self': A |
761 | [53; 55) '{}': () | 786 | [38; 39) 'x': u32 |
762 | [103; 107) 'self': &A | 787 | [53; 55) '{}': () |
763 | [109; 110) 'x': u64 | 788 | [103; 107) 'self': &A |
764 | [124; 126) '{}': () | 789 | [109; 110) 'x': u64 |
765 | [144; 145) 'a': A | 790 | [124; 126) '{}': () |
766 | [150; 198) '{ ...(1); }': () | 791 | [144; 145) 'a': A |
767 | [156; 157) 'a': A | 792 | [150; 198) '{ ...(1); }': () |
768 | [156; 164) 'a.foo(1)': i32 | 793 | [156; 157) 'a': A |
769 | [162; 163) '1': u32 | 794 | [156; 164) 'a.foo(1)': i32 |
770 | [170; 181) '(&a).bar(1)': i64 | 795 | [162; 163) '1': u32 |
771 | [171; 173) '&a': &A | 796 | [170; 181) '(&a).bar(1)': i64 |
772 | [172; 173) 'a': A | 797 | [171; 173) '&a': &A |
773 | [179; 180) '1': u64 | 798 | [172; 173) 'a': A |
774 | [187; 188) 'a': A | 799 | [179; 180) '1': u64 |
775 | [187; 195) 'a.bar(1)': i64 | 800 | [187; 188) 'a': A |
776 | [193; 194) '1': u64"### | 801 | [187; 195) 'a.bar(1)': i64 |
802 | [193; 194) '1': u64 | ||
803 | "### | ||
777 | ); | 804 | ); |
778 | } | 805 | } |
779 | 806 | ||
780 | #[test] | 807 | #[test] |
781 | fn infer_inherent_method_str() { | 808 | fn infer_inherent_method_str() { |
782 | assert_snapshot_matches!( | 809 | assert_snapshot!( |
783 | infer(r#" | 810 | infer(r#" |
784 | #[lang = "str"] | 811 | #[lang = "str"] |
785 | impl str { | 812 | impl str { |
@@ -791,17 +818,19 @@ fn test() { | |||
791 | } | 818 | } |
792 | "#), | 819 | "#), |
793 | @r###" | 820 | @r###" |
794 | [40; 44) 'self': &str | 821 | |
795 | [53; 55) '{}': () | 822 | [40; 44) 'self': &str |
796 | [69; 89) '{ ...o(); }': () | 823 | [53; 55) '{}': () |
797 | [75; 80) '"foo"': &str | 824 | [69; 89) '{ ...o(); }': () |
798 | [75; 86) '"foo".foo()': i32"### | 825 | [75; 80) '"foo"': &str |
826 | [75; 86) '"foo".foo()': i32 | ||
827 | "### | ||
799 | ); | 828 | ); |
800 | } | 829 | } |
801 | 830 | ||
802 | #[test] | 831 | #[test] |
803 | fn infer_tuple() { | 832 | fn infer_tuple() { |
804 | assert_snapshot_matches!( | 833 | assert_snapshot!( |
805 | infer(r#" | 834 | infer(r#" |
806 | fn test(x: &str, y: isize) { | 835 | fn test(x: &str, y: isize) { |
807 | let a: (u32, &str) = (1, "a"); | 836 | let a: (u32, &str) = (1, "a"); |
@@ -813,39 +842,41 @@ fn test(x: &str, y: isize) { | |||
813 | } | 842 | } |
814 | "#), | 843 | "#), |
815 | @r###" | 844 | @r###" |
816 | [9; 10) 'x': &str | 845 | |
817 | [18; 19) 'y': isize | 846 | [9; 10) 'x': &str |
818 | [28; 170) '{ ...d"); }': () | 847 | [18; 19) 'y': isize |
819 | [38; 39) 'a': (u32, &str) | 848 | [28; 170) '{ ...d"); }': () |
820 | [55; 63) '(1, "a")': (u32, &str) | 849 | [38; 39) 'a': (u32, &str) |
821 | [56; 57) '1': u32 | 850 | [55; 63) '(1, "a")': (u32, &str) |
822 | [59; 62) '"a"': &str | 851 | [56; 57) '1': u32 |
823 | [73; 74) 'b': ((u32, &str), &str) | 852 | [59; 62) '"a"': &str |
824 | [77; 83) '(a, x)': ((u32, &str), &str) | 853 | [73; 74) 'b': ((u32, &str), &str) |
825 | [78; 79) 'a': (u32, &str) | 854 | [77; 83) '(a, x)': ((u32, &str), &str) |
826 | [81; 82) 'x': &str | 855 | [78; 79) 'a': (u32, &str) |
827 | [93; 94) 'c': (isize, &str) | 856 | [81; 82) 'x': &str |
828 | [97; 103) '(y, x)': (isize, &str) | 857 | [93; 94) 'c': (isize, &str) |
829 | [98; 99) 'y': isize | 858 | [97; 103) '(y, x)': (isize, &str) |
830 | [101; 102) 'x': &str | 859 | [98; 99) 'y': isize |
831 | [113; 114) 'd': ((isize, &str), &str) | 860 | [101; 102) 'x': &str |
832 | [117; 123) '(c, x)': ((isize, &str), &str) | 861 | [113; 114) 'd': ((isize, &str), &str) |
833 | [118; 119) 'c': (isize, &str) | 862 | [117; 123) '(c, x)': ((isize, &str), &str) |
834 | [121; 122) 'x': &str | 863 | [118; 119) 'c': (isize, &str) |
835 | [133; 134) 'e': (i32, &str) | 864 | [121; 122) 'x': &str |
836 | [137; 145) '(1, "e")': (i32, &str) | 865 | [133; 134) 'e': (i32, &str) |
837 | [138; 139) '1': i32 | 866 | [137; 145) '(1, "e")': (i32, &str) |
838 | [141; 144) '"e"': &str | 867 | [138; 139) '1': i32 |
839 | [155; 156) 'f': ((i32, &str), &str) | 868 | [141; 144) '"e"': &str |
840 | [159; 167) '(e, "d")': ((i32, &str), &str) | 869 | [155; 156) 'f': ((i32, &str), &str) |
841 | [160; 161) 'e': (i32, &str) | 870 | [159; 167) '(e, "d")': ((i32, &str), &str) |
842 | [163; 166) '"d"': &str"### | 871 | [160; 161) 'e': (i32, &str) |
872 | [163; 166) '"d"': &str | ||
873 | "### | ||
843 | ); | 874 | ); |
844 | } | 875 | } |
845 | 876 | ||
846 | #[test] | 877 | #[test] |
847 | fn infer_array() { | 878 | fn infer_array() { |
848 | assert_snapshot_matches!( | 879 | assert_snapshot!( |
849 | infer(r#" | 880 | infer(r#" |
850 | fn test(x: &str, y: isize) { | 881 | fn test(x: &str, y: isize) { |
851 | let a = [x]; | 882 | let a = [x]; |
@@ -867,70 +898,72 @@ fn test(x: &str, y: isize) { | |||
867 | } | 898 | } |
868 | "#), | 899 | "#), |
869 | @r###" | 900 | @r###" |
870 | [9; 10) 'x': &str | 901 | |
871 | [18; 19) 'y': isize | 902 | [9; 10) 'x': &str |
872 | [28; 324) '{ ... 3]; }': () | 903 | [18; 19) 'y': isize |
873 | [38; 39) 'a': [&str;_] | 904 | [28; 324) '{ ... 3]; }': () |
874 | [42; 45) '[x]': [&str;_] | 905 | [38; 39) 'a': [&str;_] |
875 | [43; 44) 'x': &str | 906 | [42; 45) '[x]': [&str;_] |
876 | [55; 56) 'b': [[&str;_];_] | 907 | [43; 44) 'x': &str |
877 | [59; 65) '[a, a]': [[&str;_];_] | 908 | [55; 56) 'b': [[&str;_];_] |
878 | [60; 61) 'a': [&str;_] | 909 | [59; 65) '[a, a]': [[&str;_];_] |
879 | [63; 64) 'a': [&str;_] | 910 | [60; 61) 'a': [&str;_] |
880 | [75; 76) 'c': [[[&str;_];_];_] | 911 | [63; 64) 'a': [&str;_] |
881 | [79; 85) '[b, b]': [[[&str;_];_];_] | 912 | [75; 76) 'c': [[[&str;_];_];_] |
882 | [80; 81) 'b': [[&str;_];_] | 913 | [79; 85) '[b, b]': [[[&str;_];_];_] |
883 | [83; 84) 'b': [[&str;_];_] | 914 | [80; 81) 'b': [[&str;_];_] |
884 | [96; 97) 'd': [isize;_] | 915 | [83; 84) 'b': [[&str;_];_] |
885 | [100; 112) '[y, 1, 2, 3]': [isize;_] | 916 | [96; 97) 'd': [isize;_] |
886 | [101; 102) 'y': isize | 917 | [100; 112) '[y, 1, 2, 3]': [isize;_] |
887 | [104; 105) '1': isize | 918 | [101; 102) 'y': isize |
888 | [107; 108) '2': isize | 919 | [104; 105) '1': isize |
889 | [110; 111) '3': isize | 920 | [107; 108) '2': isize |
890 | [122; 123) 'd': [isize;_] | 921 | [110; 111) '3': isize |
891 | [126; 138) '[1, y, 2, 3]': [isize;_] | 922 | [122; 123) 'd': [isize;_] |
892 | [127; 128) '1': isize | 923 | [126; 138) '[1, y, 2, 3]': [isize;_] |
893 | [130; 131) 'y': isize | 924 | [127; 128) '1': isize |
894 | [133; 134) '2': isize | 925 | [130; 131) 'y': isize |
895 | [136; 137) '3': isize | 926 | [133; 134) '2': isize |
896 | [148; 149) 'e': [isize;_] | 927 | [136; 137) '3': isize |
897 | [152; 155) '[y]': [isize;_] | 928 | [148; 149) 'e': [isize;_] |
898 | [153; 154) 'y': isize | 929 | [152; 155) '[y]': [isize;_] |
899 | [165; 166) 'f': [[isize;_];_] | 930 | [153; 154) 'y': isize |
900 | [169; 175) '[d, d]': [[isize;_];_] | 931 | [165; 166) 'f': [[isize;_];_] |
901 | [170; 171) 'd': [isize;_] | 932 | [169; 175) '[d, d]': [[isize;_];_] |
902 | [173; 174) 'd': [isize;_] | 933 | [170; 171) 'd': [isize;_] |
903 | [185; 186) 'g': [[isize;_];_] | 934 | [173; 174) 'd': [isize;_] |
904 | [189; 195) '[e, e]': [[isize;_];_] | 935 | [185; 186) 'g': [[isize;_];_] |
905 | [190; 191) 'e': [isize;_] | 936 | [189; 195) '[e, e]': [[isize;_];_] |
906 | [193; 194) 'e': [isize;_] | 937 | [190; 191) 'e': [isize;_] |
907 | [206; 207) 'h': [i32;_] | 938 | [193; 194) 'e': [isize;_] |
908 | [210; 216) '[1, 2]': [i32;_] | 939 | [206; 207) 'h': [i32;_] |
909 | [211; 212) '1': i32 | 940 | [210; 216) '[1, 2]': [i32;_] |
910 | [214; 215) '2': i32 | 941 | [211; 212) '1': i32 |
911 | [226; 227) 'i': [&str;_] | 942 | [214; 215) '2': i32 |
912 | [230; 240) '["a", "b"]': [&str;_] | 943 | [226; 227) 'i': [&str;_] |
913 | [231; 234) '"a"': &str | 944 | [230; 240) '["a", "b"]': [&str;_] |
914 | [236; 239) '"b"': &str | 945 | [231; 234) '"a"': &str |
915 | [251; 252) 'b': [[&str;_];_] | 946 | [236; 239) '"b"': &str |
916 | [255; 265) '[a, ["b"]]': [[&str;_];_] | 947 | [251; 252) 'b': [[&str;_];_] |
917 | [256; 257) 'a': [&str;_] | 948 | [255; 265) '[a, ["b"]]': [[&str;_];_] |
918 | [259; 264) '["b"]': [&str;_] | 949 | [256; 257) 'a': [&str;_] |
919 | [260; 263) '"b"': &str | 950 | [259; 264) '["b"]': [&str;_] |
920 | [275; 276) 'x': [u8;_] | 951 | [260; 263) '"b"': &str |
921 | [288; 290) '[]': [u8;_] | 952 | [275; 276) 'x': [u8;_] |
922 | [300; 301) 'z': &[u8;_] | 953 | [288; 290) '[]': [u8;_] |
923 | [311; 321) '&[1, 2, 3]': &[u8;_] | 954 | [300; 301) 'z': &[u8;_] |
924 | [312; 321) '[1, 2, 3]': [u8;_] | 955 | [311; 321) '&[1, 2, 3]': &[u8;_] |
925 | [313; 314) '1': u8 | 956 | [312; 321) '[1, 2, 3]': [u8;_] |
926 | [316; 317) '2': u8 | 957 | [313; 314) '1': u8 |
927 | [319; 320) '3': u8"### | 958 | [316; 317) '2': u8 |
959 | [319; 320) '3': u8 | ||
960 | "### | ||
928 | ); | 961 | ); |
929 | } | 962 | } |
930 | 963 | ||
931 | #[test] | 964 | #[test] |
932 | fn infer_pattern() { | 965 | fn infer_pattern() { |
933 | assert_snapshot_matches!( | 966 | assert_snapshot!( |
934 | infer(r#" | 967 | infer(r#" |
935 | fn test(x: &i32) { | 968 | fn test(x: &i32) { |
936 | let y = x; | 969 | let y = x; |
@@ -955,59 +988,61 @@ fn test(x: &i32) { | |||
955 | } | 988 | } |
956 | "#), | 989 | "#), |
957 | @r###" | 990 | @r###" |
958 | [9; 10) 'x': &i32 | 991 | |
959 | [18; 369) '{ ...o_x; }': () | 992 | [9; 10) 'x': &i32 |
960 | [28; 29) 'y': &i32 | 993 | [18; 369) '{ ...o_x; }': () |
961 | [32; 33) 'x': &i32 | 994 | [28; 29) 'y': &i32 |
962 | [43; 45) '&z': &i32 | 995 | [32; 33) 'x': &i32 |
963 | [44; 45) 'z': i32 | 996 | [43; 45) '&z': &i32 |
964 | [48; 49) 'x': &i32 | 997 | [44; 45) 'z': i32 |
965 | [59; 60) 'a': i32 | 998 | [48; 49) 'x': &i32 |
966 | [63; 64) 'z': i32 | 999 | [59; 60) 'a': i32 |
967 | [74; 80) '(c, d)': (i32, &str) | 1000 | [63; 64) 'z': i32 |
968 | [75; 76) 'c': i32 | 1001 | [74; 80) '(c, d)': (i32, &str) |
969 | [78; 79) 'd': &str | 1002 | [75; 76) 'c': i32 |
970 | [83; 95) '(1, "hello")': (i32, &str) | 1003 | [78; 79) 'd': &str |
971 | [84; 85) '1': i32 | 1004 | [83; 95) '(1, "hello")': (i32, &str) |
972 | [87; 94) '"hello"': &str | 1005 | [84; 85) '1': i32 |
973 | [102; 152) 'for (e... }': () | 1006 | [87; 94) '"hello"': &str |
974 | [106; 112) '(e, f)': ({unknown}, {unknown}) | 1007 | [102; 152) 'for (e... }': () |
975 | [107; 108) 'e': {unknown} | 1008 | [106; 112) '(e, f)': ({unknown}, {unknown}) |
976 | [110; 111) 'f': {unknown} | 1009 | [107; 108) 'e': {unknown} |
977 | [116; 125) 'some_iter': {unknown} | 1010 | [110; 111) 'f': {unknown} |
978 | [126; 152) '{ ... }': () | 1011 | [116; 125) 'some_iter': {unknown} |
979 | [140; 141) 'g': {unknown} | 1012 | [126; 152) '{ ... }': () |
980 | [144; 145) 'e': {unknown} | 1013 | [140; 141) 'g': {unknown} |
981 | [158; 205) 'if let... }': () | 1014 | [144; 145) 'e': {unknown} |
982 | [165; 170) '[val]': {unknown} | 1015 | [158; 205) 'if let... }': () |
983 | [173; 176) 'opt': {unknown} | 1016 | [165; 170) '[val]': {unknown} |
984 | [177; 205) '{ ... }': () | 1017 | [173; 176) 'opt': {unknown} |
985 | [191; 192) 'h': {unknown} | 1018 | [177; 205) '{ ... }': () |
986 | [195; 198) 'val': {unknown} | 1019 | [191; 192) 'h': {unknown} |
987 | [215; 221) 'lambda': {unknown} | 1020 | [195; 198) 'val': {unknown} |
988 | [224; 256) '|a: u6...b; c }': {unknown} | 1021 | [215; 221) 'lambda': {unknown} |
989 | [225; 226) 'a': u64 | 1022 | [224; 256) '|a: u6...b; c }': {unknown} |
990 | [233; 234) 'b': u64 | 1023 | [225; 226) 'a': u64 |
991 | [236; 237) 'c': i32 | 1024 | [233; 234) 'b': u64 |
992 | [244; 256) '{ a + b; c }': i32 | 1025 | [236; 237) 'c': i32 |
993 | [246; 247) 'a': u64 | 1026 | [244; 256) '{ a + b; c }': i32 |
994 | [246; 251) 'a + b': u64 | 1027 | [246; 247) 'a': u64 |
995 | [250; 251) 'b': u64 | 1028 | [246; 251) 'a + b': u64 |
996 | [253; 254) 'c': i32 | 1029 | [250; 251) 'b': u64 |
997 | [267; 279) 'ref ref_to_x': &&i32 | 1030 | [253; 254) 'c': i32 |
998 | [282; 283) 'x': &i32 | 1031 | [267; 279) 'ref ref_to_x': &&i32 |
999 | [293; 302) 'mut mut_x': &i32 | 1032 | [282; 283) 'x': &i32 |
1000 | [305; 306) 'x': &i32 | 1033 | [293; 302) 'mut mut_x': &i32 |
1001 | [316; 336) 'ref mu...f_to_x': &mut &i32 | 1034 | [305; 306) 'x': &i32 |
1002 | [339; 340) 'x': &i32 | 1035 | [316; 336) 'ref mu...f_to_x': &mut &i32 |
1003 | [350; 351) 'k': &mut &i32 | 1036 | [339; 340) 'x': &i32 |
1004 | [354; 366) 'mut_ref_to_x': &mut &i32"### | 1037 | [350; 351) 'k': &mut &i32 |
1038 | [354; 366) 'mut_ref_to_x': &mut &i32 | ||
1039 | "### | ||
1005 | ); | 1040 | ); |
1006 | } | 1041 | } |
1007 | 1042 | ||
1008 | #[test] | 1043 | #[test] |
1009 | fn infer_pattern_match_ergonomics() { | 1044 | fn infer_pattern_match_ergonomics() { |
1010 | assert_snapshot_matches!( | 1045 | assert_snapshot!( |
1011 | infer(r#" | 1046 | infer(r#" |
1012 | struct A<T>(T); | 1047 | struct A<T>(T); |
1013 | 1048 | ||
@@ -1017,26 +1052,28 @@ fn test() { | |||
1017 | } | 1052 | } |
1018 | "#), | 1053 | "#), |
1019 | @r###" | 1054 | @r###" |
1020 | [28; 79) '{ ...(1); }': () | 1055 | |
1021 | [38; 42) 'A(n)': A<i32> | 1056 | [28; 79) '{ ...(1); }': () |
1022 | [40; 41) 'n': &i32 | 1057 | [38; 42) 'A(n)': A<i32> |
1023 | [45; 50) '&A(1)': &A<i32> | 1058 | [40; 41) 'n': &i32 |
1024 | [46; 47) 'A': A<i32>(T) -> A<T> | 1059 | [45; 50) '&A(1)': &A<i32> |
1025 | [46; 50) 'A(1)': A<i32> | 1060 | [46; 47) 'A': A<i32>(T) -> A<T> |
1026 | [48; 49) '1': i32 | 1061 | [46; 50) 'A(1)': A<i32> |
1027 | [60; 64) 'A(n)': A<i32> | 1062 | [48; 49) '1': i32 |
1028 | [62; 63) 'n': &mut i32 | 1063 | [60; 64) 'A(n)': A<i32> |
1029 | [67; 76) '&mut A(1)': &mut A<i32> | 1064 | [62; 63) 'n': &mut i32 |
1030 | [72; 73) 'A': A<i32>(T) -> A<T> | 1065 | [67; 76) '&mut A(1)': &mut A<i32> |
1031 | [72; 76) 'A(1)': A<i32> | 1066 | [72; 73) 'A': A<i32>(T) -> A<T> |
1032 | [74; 75) '1': i32"### | 1067 | [72; 76) 'A(1)': A<i32> |
1068 | [74; 75) '1': i32 | ||
1069 | "### | ||
1033 | ); | 1070 | ); |
1034 | } | 1071 | } |
1035 | 1072 | ||
1036 | #[test] | 1073 | #[test] |
1037 | fn infer_pattern_match_ergonomics_ref() { | 1074 | fn infer_pattern_match_ergonomics_ref() { |
1038 | covers!(match_ergonomics_ref); | 1075 | covers!(match_ergonomics_ref); |
1039 | assert_snapshot_matches!( | 1076 | assert_snapshot!( |
1040 | infer(r#" | 1077 | infer(r#" |
1041 | fn test() { | 1078 | fn test() { |
1042 | let v = &(1, &2); | 1079 | let v = &(1, &2); |
@@ -1044,24 +1081,26 @@ fn test() { | |||
1044 | } | 1081 | } |
1045 | "#), | 1082 | "#), |
1046 | @r###" | 1083 | @r###" |
1047 | [11; 57) '{ ...= v; }': () | 1084 | |
1048 | [21; 22) 'v': &(i32, &i32) | 1085 | [11; 57) '{ ...= v; }': () |
1049 | [25; 33) '&(1, &2)': &(i32, &i32) | 1086 | [21; 22) 'v': &(i32, &i32) |
1050 | [26; 33) '(1, &2)': (i32, &i32) | 1087 | [25; 33) '&(1, &2)': &(i32, &i32) |
1051 | [27; 28) '1': i32 | 1088 | [26; 33) '(1, &2)': (i32, &i32) |
1052 | [30; 32) '&2': &i32 | 1089 | [27; 28) '1': i32 |
1053 | [31; 32) '2': i32 | 1090 | [30; 32) '&2': &i32 |
1054 | [43; 50) '(_, &w)': (i32, &i32) | 1091 | [31; 32) '2': i32 |
1055 | [44; 45) '_': i32 | 1092 | [43; 50) '(_, &w)': (i32, &i32) |
1056 | [47; 49) '&w': &i32 | 1093 | [44; 45) '_': i32 |
1057 | [48; 49) 'w': i32 | 1094 | [47; 49) '&w': &i32 |
1058 | [53; 54) 'v': &(i32, &i32)"### | 1095 | [48; 49) 'w': i32 |
1096 | [53; 54) 'v': &(i32, &i32) | ||
1097 | "### | ||
1059 | ); | 1098 | ); |
1060 | } | 1099 | } |
1061 | 1100 | ||
1062 | #[test] | 1101 | #[test] |
1063 | fn infer_adt_pattern() { | 1102 | fn infer_adt_pattern() { |
1064 | assert_snapshot_matches!( | 1103 | assert_snapshot!( |
1065 | infer(r#" | 1104 | infer(r#" |
1066 | enum E { | 1105 | enum E { |
1067 | A { x: usize }, | 1106 | A { x: usize }, |
@@ -1087,37 +1126,39 @@ fn test() { | |||
1087 | } | 1126 | } |
1088 | "#), | 1127 | "#), |
1089 | @r###" | 1128 | @r###" |
1090 | [68; 289) '{ ... d; }': () | 1129 | |
1091 | [78; 79) 'e': E | 1130 | [68; 289) '{ ... d; }': () |
1092 | [82; 95) 'E::A { x: 3 }': E | 1131 | [78; 79) 'e': E |
1093 | [92; 93) '3': usize | 1132 | [82; 95) 'E::A { x: 3 }': E |
1094 | [106; 113) 'S(y, z)': S | 1133 | [92; 93) '3': usize |
1095 | [108; 109) 'y': u32 | 1134 | [106; 113) 'S(y, z)': S |
1096 | [111; 112) 'z': E | 1135 | [108; 109) 'y': u32 |
1097 | [116; 119) 'foo': S | 1136 | [111; 112) 'z': E |
1098 | [129; 148) 'E::A {..._var }': E | 1137 | [116; 119) 'foo': S |
1099 | [139; 146) 'new_var': usize | 1138 | [129; 148) 'E::A {..._var }': E |
1100 | [151; 152) 'e': E | 1139 | [139; 146) 'new_var': usize |
1101 | [159; 245) 'match ... }': usize | 1140 | [151; 152) 'e': E |
1102 | [165; 166) 'e': E | 1141 | [159; 245) 'match ... }': usize |
1103 | [177; 187) 'E::A { x }': E | 1142 | [165; 166) 'e': E |
1104 | [184; 185) 'x': usize | 1143 | [177; 187) 'E::A { x }': E |
1105 | [191; 192) 'x': usize | 1144 | [184; 185) 'x': usize |
1106 | [202; 206) 'E::B': E | 1145 | [191; 192) 'x': usize |
1107 | [210; 213) 'foo': bool | 1146 | [202; 206) 'E::B': E |
1108 | [217; 218) '1': usize | 1147 | [210; 213) 'foo': bool |
1109 | [228; 232) 'E::B': E | 1148 | [217; 218) '1': usize |
1110 | [236; 238) '10': usize | 1149 | [228; 232) 'E::B': E |
1111 | [256; 275) 'ref d ...{ .. }': &E | 1150 | [236; 238) '10': usize |
1112 | [264; 275) 'E::A { .. }': E | 1151 | [256; 275) 'ref d ...{ .. }': &E |
1113 | [278; 279) 'e': E | 1152 | [264; 275) 'E::A { .. }': E |
1114 | [285; 286) 'd': &E"### | 1153 | [278; 279) 'e': E |
1154 | [285; 286) 'd': &E | ||
1155 | "### | ||
1115 | ); | 1156 | ); |
1116 | } | 1157 | } |
1117 | 1158 | ||
1118 | #[test] | 1159 | #[test] |
1119 | fn infer_struct_generics() { | 1160 | fn infer_struct_generics() { |
1120 | assert_snapshot_matches!( | 1161 | assert_snapshot!( |
1121 | infer(r#" | 1162 | infer(r#" |
1122 | struct A<T> { | 1163 | struct A<T> { |
1123 | x: T, | 1164 | x: T, |
@@ -1132,27 +1173,29 @@ fn test(a1: A<u32>, i: i32) { | |||
1132 | } | 1173 | } |
1133 | "#), | 1174 | "#), |
1134 | @r###" | 1175 | @r###" |
1135 | [36; 38) 'a1': A<u32> | 1176 | |
1136 | [48; 49) 'i': i32 | 1177 | [36; 38) 'a1': A<u32> |
1137 | [56; 147) '{ ...3.x; }': () | 1178 | [48; 49) 'i': i32 |
1138 | [62; 64) 'a1': A<u32> | 1179 | [56; 147) '{ ...3.x; }': () |
1139 | [62; 66) 'a1.x': u32 | 1180 | [62; 64) 'a1': A<u32> |
1140 | [76; 78) 'a2': A<i32> | 1181 | [62; 66) 'a1.x': u32 |
1141 | [81; 91) 'A { x: i }': A<i32> | 1182 | [76; 78) 'a2': A<i32> |
1142 | [88; 89) 'i': i32 | 1183 | [81; 91) 'A { x: i }': A<i32> |
1143 | [97; 99) 'a2': A<i32> | 1184 | [88; 89) 'i': i32 |
1144 | [97; 101) 'a2.x': i32 | 1185 | [97; 99) 'a2': A<i32> |
1145 | [111; 113) 'a3': A<i128> | 1186 | [97; 101) 'a2.x': i32 |
1146 | [116; 134) 'A::<i1...x: 1 }': A<i128> | 1187 | [111; 113) 'a3': A<i128> |
1147 | [131; 132) '1': i128 | 1188 | [116; 134) 'A::<i1...x: 1 }': A<i128> |
1148 | [140; 142) 'a3': A<i128> | 1189 | [131; 132) '1': i128 |
1149 | [140; 144) 'a3.x': i128"### | 1190 | [140; 142) 'a3': A<i128> |
1191 | [140; 144) 'a3.x': i128 | ||
1192 | "### | ||
1150 | ); | 1193 | ); |
1151 | } | 1194 | } |
1152 | 1195 | ||
1153 | #[test] | 1196 | #[test] |
1154 | fn infer_tuple_struct_generics() { | 1197 | fn infer_tuple_struct_generics() { |
1155 | assert_snapshot_matches!( | 1198 | assert_snapshot!( |
1156 | infer(r#" | 1199 | infer(r#" |
1157 | struct A<T>(T); | 1200 | struct A<T>(T); |
1158 | enum Option<T> { Some(T), None } | 1201 | enum Option<T> { Some(T), None } |
@@ -1168,30 +1211,29 @@ fn test() { | |||
1168 | } | 1211 | } |
1169 | "#), | 1212 | "#), |
1170 | @r###" | 1213 | @r###" |
1171 | ⋮ | 1214 | [76; 184) '{ ...one; }': () |
1172 | ⋮[76; 184) '{ ...one; }': () | 1215 | [82; 83) 'A': A<i32>(T) -> A<T> |
1173 | ⋮[82; 83) 'A': A<i32>(T) -> A<T> | 1216 | [82; 87) 'A(42)': A<i32> |
1174 | ⋮[82; 87) 'A(42)': A<i32> | 1217 | [84; 86) '42': i32 |
1175 | ⋮[84; 86) '42': i32 | 1218 | [93; 94) 'A': A<u128>(T) -> A<T> |
1176 | ⋮[93; 94) 'A': A<u128>(T) -> A<T> | 1219 | [93; 102) 'A(42u128)': A<u128> |
1177 | ⋮[93; 102) 'A(42u128)': A<u128> | 1220 | [95; 101) '42u128': u128 |
1178 | ⋮[95; 101) '42u128': u128 | 1221 | [108; 112) 'Some': Some<&str>(T) -> Option<T> |
1179 | ⋮[108; 112) 'Some': Some<&str>(T) -> Option<T> | 1222 | [108; 117) 'Some("x")': Option<&str> |
1180 | ⋮[108; 117) 'Some("x")': Option<&str> | 1223 | [113; 116) '"x"': &str |
1181 | ⋮[113; 116) '"x"': &str | 1224 | [123; 135) 'Option::Some': Some<&str>(T) -> Option<T> |
1182 | ⋮[123; 135) 'Option::Some': Some<&str>(T) -> Option<T> | 1225 | [123; 140) 'Option...e("x")': Option<&str> |
1183 | ⋮[123; 140) 'Option...e("x")': Option<&str> | 1226 | [136; 139) '"x"': &str |
1184 | ⋮[136; 139) '"x"': &str | 1227 | [146; 150) 'None': Option<{unknown}> |
1185 | ⋮[146; 150) 'None': Option<{unknown}> | 1228 | [160; 161) 'x': Option<i64> |
1186 | ⋮[160; 161) 'x': Option<i64> | 1229 | [177; 181) 'None': Option<i64> |
1187 | ⋮[177; 181) 'None': Option<i64> | ||
1188 | "### | 1230 | "### |
1189 | ); | 1231 | ); |
1190 | } | 1232 | } |
1191 | 1233 | ||
1192 | #[test] | 1234 | #[test] |
1193 | fn infer_generics_in_patterns() { | 1235 | fn infer_generics_in_patterns() { |
1194 | assert_snapshot_matches!( | 1236 | assert_snapshot!( |
1195 | infer(r#" | 1237 | infer(r#" |
1196 | struct A<T> { | 1238 | struct A<T> { |
1197 | x: T, | 1239 | x: T, |
@@ -1212,29 +1254,31 @@ fn test(a1: A<u32>, o: Option<u64>) { | |||
1212 | } | 1254 | } |
1213 | "#), | 1255 | "#), |
1214 | @r###" | 1256 | @r###" |
1215 | [79; 81) 'a1': A<u32> | 1257 | |
1216 | [91; 92) 'o': Option<u64> | 1258 | [79; 81) 'a1': A<u32> |
1217 | [107; 244) '{ ... }; }': () | 1259 | [91; 92) 'o': Option<u64> |
1218 | [117; 128) 'A { x: x2 }': A<u32> | 1260 | [107; 244) '{ ... }; }': () |
1219 | [124; 126) 'x2': u32 | 1261 | [117; 128) 'A { x: x2 }': A<u32> |
1220 | [131; 133) 'a1': A<u32> | 1262 | [124; 126) 'x2': u32 |
1221 | [143; 161) 'A::<i6...: x3 }': A<i64> | 1263 | [131; 133) 'a1': A<u32> |
1222 | [157; 159) 'x3': i64 | 1264 | [143; 161) 'A::<i6...: x3 }': A<i64> |
1223 | [164; 174) 'A { x: 1 }': A<i64> | 1265 | [157; 159) 'x3': i64 |
1224 | [171; 172) '1': i64 | 1266 | [164; 174) 'A { x: 1 }': A<i64> |
1225 | [180; 241) 'match ... }': u64 | 1267 | [171; 172) '1': i64 |
1226 | [186; 187) 'o': Option<u64> | 1268 | [180; 241) 'match ... }': u64 |
1227 | [198; 213) 'Option::Some(t)': Option<u64> | 1269 | [186; 187) 'o': Option<u64> |
1228 | [211; 212) 't': u64 | 1270 | [198; 213) 'Option::Some(t)': Option<u64> |
1229 | [217; 218) 't': u64 | 1271 | [211; 212) 't': u64 |
1230 | [228; 229) '_': Option<u64> | 1272 | [217; 218) 't': u64 |
1231 | [233; 234) '1': u64"### | 1273 | [228; 229) '_': Option<u64> |
1274 | [233; 234) '1': u64 | ||
1275 | "### | ||
1232 | ); | 1276 | ); |
1233 | } | 1277 | } |
1234 | 1278 | ||
1235 | #[test] | 1279 | #[test] |
1236 | fn infer_function_generics() { | 1280 | fn infer_function_generics() { |
1237 | assert_snapshot_matches!( | 1281 | assert_snapshot!( |
1238 | infer(r#" | 1282 | infer(r#" |
1239 | fn id<T>(t: T) -> T { t } | 1283 | fn id<T>(t: T) -> T { t } |
1240 | 1284 | ||
@@ -1245,26 +1289,28 @@ fn test() { | |||
1245 | } | 1289 | } |
1246 | "#), | 1290 | "#), |
1247 | @r###" | 1291 | @r###" |
1248 | [10; 11) 't': T | 1292 | |
1249 | [21; 26) '{ t }': T | 1293 | [10; 11) 't': T |
1250 | [23; 24) 't': T | 1294 | [21; 26) '{ t }': T |
1251 | [38; 98) '{ ...(1); }': () | 1295 | [23; 24) 't': T |
1252 | [44; 46) 'id': fn id<u32>(T) -> T | 1296 | [38; 98) '{ ...(1); }': () |
1253 | [44; 52) 'id(1u32)': u32 | 1297 | [44; 46) 'id': fn id<u32>(T) -> T |
1254 | [47; 51) '1u32': u32 | 1298 | [44; 52) 'id(1u32)': u32 |
1255 | [58; 68) 'id::<i128>': fn id<i128>(T) -> T | 1299 | [47; 51) '1u32': u32 |
1256 | [58; 71) 'id::<i128>(1)': i128 | 1300 | [58; 68) 'id::<i128>': fn id<i128>(T) -> T |
1257 | [69; 70) '1': i128 | 1301 | [58; 71) 'id::<i128>(1)': i128 |
1258 | [81; 82) 'x': u64 | 1302 | [69; 70) '1': i128 |
1259 | [90; 92) 'id': fn id<u64>(T) -> T | 1303 | [81; 82) 'x': u64 |
1260 | [90; 95) 'id(1)': u64 | 1304 | [90; 92) 'id': fn id<u64>(T) -> T |
1261 | [93; 94) '1': u64"### | 1305 | [90; 95) 'id(1)': u64 |
1306 | [93; 94) '1': u64 | ||
1307 | "### | ||
1262 | ); | 1308 | ); |
1263 | } | 1309 | } |
1264 | 1310 | ||
1265 | #[test] | 1311 | #[test] |
1266 | fn infer_impl_generics() { | 1312 | fn infer_impl_generics() { |
1267 | assert_snapshot_matches!( | 1313 | assert_snapshot!( |
1268 | infer(r#" | 1314 | infer(r#" |
1269 | struct A<T1, T2> { | 1315 | struct A<T1, T2> { |
1270 | x: T1, | 1316 | x: T1, |
@@ -1291,44 +1337,46 @@ fn test() -> i128 { | |||
1291 | } | 1337 | } |
1292 | "#), | 1338 | "#), |
1293 | @r###" | 1339 | @r###" |
1294 | [74; 78) 'self': A<X, Y> | 1340 | |
1295 | [85; 107) '{ ... }': X | 1341 | [74; 78) 'self': A<X, Y> |
1296 | [95; 99) 'self': A<X, Y> | 1342 | [85; 107) '{ ... }': X |
1297 | [95; 101) 'self.x': X | 1343 | [95; 99) 'self': A<X, Y> |
1298 | [117; 121) 'self': A<X, Y> | 1344 | [95; 101) 'self.x': X |
1299 | [128; 150) '{ ... }': Y | 1345 | [117; 121) 'self': A<X, Y> |
1300 | [138; 142) 'self': A<X, Y> | 1346 | [128; 150) '{ ... }': Y |
1301 | [138; 144) 'self.y': Y | 1347 | [138; 142) 'self': A<X, Y> |
1302 | [163; 167) 'self': A<X, Y> | 1348 | [138; 144) 'self.y': Y |
1303 | [169; 170) 't': T | 1349 | [163; 167) 'self': A<X, Y> |
1304 | [188; 223) '{ ... }': (X, Y, T) | 1350 | [169; 170) 't': T |
1305 | [198; 217) '(self.....y, t)': (X, Y, T) | 1351 | [188; 223) '{ ... }': (X, Y, T) |
1306 | [199; 203) 'self': A<X, Y> | 1352 | [198; 217) '(self.....y, t)': (X, Y, T) |
1307 | [199; 205) 'self.x': X | 1353 | [199; 203) 'self': A<X, Y> |
1308 | [207; 211) 'self': A<X, Y> | 1354 | [199; 205) 'self.x': X |
1309 | [207; 213) 'self.y': Y | 1355 | [207; 211) 'self': A<X, Y> |
1310 | [215; 216) 't': T | 1356 | [207; 213) 'self.y': Y |
1311 | [245; 342) '{ ...(1); }': () | 1357 | [215; 216) 't': T |
1312 | [255; 256) 'a': A<u64, i64> | 1358 | [245; 342) '{ ...(1); }': () |
1313 | [259; 281) 'A { x:...1i64 }': A<u64, i64> | 1359 | [255; 256) 'a': A<u64, i64> |
1314 | [266; 270) '1u64': u64 | 1360 | [259; 281) 'A { x:...1i64 }': A<u64, i64> |
1315 | [275; 279) '1i64': i64 | 1361 | [266; 270) '1u64': u64 |
1316 | [287; 288) 'a': A<u64, i64> | 1362 | [275; 279) '1i64': i64 |
1317 | [287; 292) 'a.x()': u64 | 1363 | [287; 288) 'a': A<u64, i64> |
1318 | [298; 299) 'a': A<u64, i64> | 1364 | [287; 292) 'a.x()': u64 |
1319 | [298; 303) 'a.y()': i64 | 1365 | [298; 299) 'a': A<u64, i64> |
1320 | [309; 310) 'a': A<u64, i64> | 1366 | [298; 303) 'a.y()': i64 |
1321 | [309; 319) 'a.z(1i128)': (u64, i64, i128) | 1367 | [309; 310) 'a': A<u64, i64> |
1322 | [313; 318) '1i128': i128 | 1368 | [309; 319) 'a.z(1i128)': (u64, i64, i128) |
1323 | [325; 326) 'a': A<u64, i64> | 1369 | [313; 318) '1i128': i128 |
1324 | [325; 339) 'a.z::<u128>(1)': (u64, i64, u128) | 1370 | [325; 326) 'a': A<u64, i64> |
1325 | [337; 338) '1': u128"### | 1371 | [325; 339) 'a.z::<u128>(1)': (u64, i64, u128) |
1372 | [337; 338) '1': u128 | ||
1373 | "### | ||
1326 | ); | 1374 | ); |
1327 | } | 1375 | } |
1328 | 1376 | ||
1329 | #[test] | 1377 | #[test] |
1330 | fn infer_impl_generics_with_autoderef() { | 1378 | fn infer_impl_generics_with_autoderef() { |
1331 | assert_snapshot_matches!( | 1379 | assert_snapshot!( |
1332 | infer(r#" | 1380 | infer(r#" |
1333 | enum Option<T> { | 1381 | enum Option<T> { |
1334 | Some(T), | 1382 | Some(T), |
@@ -1343,21 +1391,23 @@ fn test(o: Option<u32>) { | |||
1343 | } | 1391 | } |
1344 | "#), | 1392 | "#), |
1345 | @r###" | 1393 | @r###" |
1346 | [78; 82) 'self': &Option<T> | 1394 | |
1347 | [98; 100) '{}': () | 1395 | [78; 82) 'self': &Option<T> |
1348 | [111; 112) 'o': Option<u32> | 1396 | [98; 100) '{}': () |
1349 | [127; 165) '{ ...f(); }': () | 1397 | [111; 112) 'o': Option<u32> |
1350 | [133; 146) '(&o).as_ref()': Option<&u32> | 1398 | [127; 165) '{ ...f(); }': () |
1351 | [134; 136) '&o': &Option<u32> | 1399 | [133; 146) '(&o).as_ref()': Option<&u32> |
1352 | [135; 136) 'o': Option<u32> | 1400 | [134; 136) '&o': &Option<u32> |
1353 | [152; 153) 'o': Option<u32> | 1401 | [135; 136) 'o': Option<u32> |
1354 | [152; 162) 'o.as_ref()': Option<&u32>"### | 1402 | [152; 153) 'o': Option<u32> |
1403 | [152; 162) 'o.as_ref()': Option<&u32> | ||
1404 | "### | ||
1355 | ); | 1405 | ); |
1356 | } | 1406 | } |
1357 | 1407 | ||
1358 | #[test] | 1408 | #[test] |
1359 | fn infer_generic_chain() { | 1409 | fn infer_generic_chain() { |
1360 | assert_snapshot_matches!( | 1410 | assert_snapshot!( |
1361 | infer(r#" | 1411 | infer(r#" |
1362 | struct A<T> { | 1412 | struct A<T> { |
1363 | x: T, | 1413 | x: T, |
@@ -1379,41 +1429,43 @@ fn test() -> i128 { | |||
1379 | } | 1429 | } |
1380 | "#), | 1430 | "#), |
1381 | @r###" | 1431 | @r###" |
1382 | [53; 57) 'self': A<T2> | 1432 | |
1383 | [65; 87) '{ ... }': T2 | 1433 | [53; 57) 'self': A<T2> |
1384 | [75; 79) 'self': A<T2> | 1434 | [65; 87) '{ ... }': T2 |
1385 | [75; 81) 'self.x': T2 | 1435 | [75; 79) 'self': A<T2> |
1386 | [99; 100) 't': T | 1436 | [75; 81) 'self.x': T2 |
1387 | [110; 115) '{ t }': T | 1437 | [99; 100) 't': T |
1388 | [112; 113) 't': T | 1438 | [110; 115) '{ t }': T |
1389 | [135; 261) '{ ....x() }': i128 | 1439 | [112; 113) 't': T |
1390 | [146; 147) 'x': i128 | 1440 | [135; 261) '{ ....x() }': i128 |
1391 | [150; 151) '1': i128 | 1441 | [146; 147) 'x': i128 |
1392 | [162; 163) 'y': i128 | 1442 | [150; 151) '1': i128 |
1393 | [166; 168) 'id': fn id<i128>(T) -> T | 1443 | [162; 163) 'y': i128 |
1394 | [166; 171) 'id(x)': i128 | 1444 | [166; 168) 'id': fn id<i128>(T) -> T |
1395 | [169; 170) 'x': i128 | 1445 | [166; 171) 'id(x)': i128 |
1396 | [182; 183) 'a': A<i128> | 1446 | [169; 170) 'x': i128 |
1397 | [186; 200) 'A { x: id(y) }': A<i128> | 1447 | [182; 183) 'a': A<i128> |
1398 | [193; 195) 'id': fn id<i128>(T) -> T | 1448 | [186; 200) 'A { x: id(y) }': A<i128> |
1399 | [193; 198) 'id(y)': i128 | 1449 | [193; 195) 'id': fn id<i128>(T) -> T |
1400 | [196; 197) 'y': i128 | 1450 | [193; 198) 'id(y)': i128 |
1401 | [211; 212) 'z': i128 | 1451 | [196; 197) 'y': i128 |
1402 | [215; 217) 'id': fn id<i128>(T) -> T | 1452 | [211; 212) 'z': i128 |
1403 | [215; 222) 'id(a.x)': i128 | 1453 | [215; 217) 'id': fn id<i128>(T) -> T |
1404 | [218; 219) 'a': A<i128> | 1454 | [215; 222) 'id(a.x)': i128 |
1405 | [218; 221) 'a.x': i128 | 1455 | [218; 219) 'a': A<i128> |
1406 | [233; 234) 'b': A<i128> | 1456 | [218; 221) 'a.x': i128 |
1407 | [237; 247) 'A { x: z }': A<i128> | 1457 | [233; 234) 'b': A<i128> |
1408 | [244; 245) 'z': i128 | 1458 | [237; 247) 'A { x: z }': A<i128> |
1409 | [254; 255) 'b': A<i128> | 1459 | [244; 245) 'z': i128 |
1410 | [254; 259) 'b.x()': i128"### | 1460 | [254; 255) 'b': A<i128> |
1461 | [254; 259) 'b.x()': i128 | ||
1462 | "### | ||
1411 | ); | 1463 | ); |
1412 | } | 1464 | } |
1413 | 1465 | ||
1414 | #[test] | 1466 | #[test] |
1415 | fn infer_associated_const() { | 1467 | fn infer_associated_const() { |
1416 | assert_snapshot_matches!( | 1468 | assert_snapshot!( |
1417 | infer(r#" | 1469 | infer(r#" |
1418 | struct Struct; | 1470 | struct Struct; |
1419 | 1471 | ||
@@ -1444,24 +1496,23 @@ fn test() { | |||
1444 | } | 1496 | } |
1445 | "#), | 1497 | "#), |
1446 | @r###" | 1498 | @r###" |
1447 | ⋮ | 1499 | [52; 53) '1': u32 |
1448 | ⋮[52; 53) '1': u32 | 1500 | [105; 106) '2': u32 |
1449 | ⋮[105; 106) '2': u32 | 1501 | [213; 214) '5': u32 |
1450 | ⋮[213; 214) '5': u32 | 1502 | [229; 307) '{ ...:ID; }': () |
1451 | ⋮[229; 307) '{ ...:ID; }': () | 1503 | [239; 240) 'x': u32 |
1452 | ⋮[239; 240) 'x': u32 | 1504 | [243; 254) 'Struct::FOO': u32 |
1453 | ⋮[243; 254) 'Struct::FOO': u32 | 1505 | [264; 265) 'y': u32 |
1454 | ⋮[264; 265) 'y': u32 | 1506 | [268; 277) 'Enum::BAR': u32 |
1455 | ⋮[268; 277) 'Enum::BAR': u32 | 1507 | [287; 288) 'z': {unknown} |
1456 | ⋮[287; 288) 'z': {unknown} | 1508 | [291; 304) 'TraitTest::ID': {unknown} |
1457 | ⋮[291; 304) 'TraitTest::ID': {unknown} | ||
1458 | "### | 1509 | "### |
1459 | ); | 1510 | ); |
1460 | } | 1511 | } |
1461 | 1512 | ||
1462 | #[test] | 1513 | #[test] |
1463 | fn infer_associated_method_struct() { | 1514 | fn infer_associated_method_struct() { |
1464 | assert_snapshot_matches!( | 1515 | assert_snapshot!( |
1465 | infer(r#" | 1516 | infer(r#" |
1466 | struct A { x: u32 } | 1517 | struct A { x: u32 } |
1467 | 1518 | ||
@@ -1476,23 +1527,22 @@ fn test() { | |||
1476 | } | 1527 | } |
1477 | "#), | 1528 | "#), |
1478 | @r###" | 1529 | @r###" |
1479 | ⋮ | 1530 | [49; 75) '{ ... }': A |
1480 | ⋮[49; 75) '{ ... }': A | 1531 | [59; 69) 'A { x: 0 }': A |
1481 | ⋮[59; 69) 'A { x: 0 }': A | 1532 | [66; 67) '0': u32 |
1482 | ⋮[66; 67) '0': u32 | 1533 | [88; 122) '{ ...a.x; }': () |
1483 | ⋮[88; 122) '{ ...a.x; }': () | 1534 | [98; 99) 'a': A |
1484 | ⋮[98; 99) 'a': A | 1535 | [102; 108) 'A::new': fn new() -> A |
1485 | ⋮[102; 108) 'A::new': fn new() -> A | 1536 | [102; 110) 'A::new()': A |
1486 | ⋮[102; 110) 'A::new()': A | 1537 | [116; 117) 'a': A |
1487 | ⋮[116; 117) 'a': A | 1538 | [116; 119) 'a.x': u32 |
1488 | ⋮[116; 119) 'a.x': u32 | ||
1489 | "### | 1539 | "### |
1490 | ); | 1540 | ); |
1491 | } | 1541 | } |
1492 | 1542 | ||
1493 | #[test] | 1543 | #[test] |
1494 | fn infer_associated_method_enum() { | 1544 | fn infer_associated_method_enum() { |
1495 | assert_snapshot_matches!( | 1545 | assert_snapshot!( |
1496 | infer(r#" | 1546 | infer(r#" |
1497 | enum A { B, C } | 1547 | enum A { B, C } |
1498 | 1548 | ||
@@ -1512,27 +1562,26 @@ fn test() { | |||
1512 | } | 1562 | } |
1513 | "#), | 1563 | "#), |
1514 | @r###" | 1564 | @r###" |
1515 | ⋮ | 1565 | [47; 67) '{ ... }': A |
1516 | ⋮[47; 67) '{ ... }': A | 1566 | [57; 61) 'A::B': A |
1517 | ⋮[57; 61) 'A::B': A | 1567 | [88; 108) '{ ... }': A |
1518 | ⋮[88; 108) '{ ... }': A | 1568 | [98; 102) 'A::C': A |
1519 | ⋮[98; 102) 'A::C': A | 1569 | [121; 178) '{ ... c; }': () |
1520 | ⋮[121; 178) '{ ... c; }': () | 1570 | [131; 132) 'a': A |
1521 | ⋮[131; 132) 'a': A | 1571 | [135; 139) 'A::b': fn b() -> A |
1522 | ⋮[135; 139) 'A::b': fn b() -> A | 1572 | [135; 141) 'A::b()': A |
1523 | ⋮[135; 141) 'A::b()': A | 1573 | [147; 148) 'a': A |
1524 | ⋮[147; 148) 'a': A | 1574 | [158; 159) 'c': A |
1525 | ⋮[158; 159) 'c': A | 1575 | [162; 166) 'A::c': fn c() -> A |
1526 | ⋮[162; 166) 'A::c': fn c() -> A | 1576 | [162; 168) 'A::c()': A |
1527 | ⋮[162; 168) 'A::c()': A | 1577 | [174; 175) 'c': A |
1528 | ⋮[174; 175) 'c': A | ||
1529 | "### | 1578 | "### |
1530 | ); | 1579 | ); |
1531 | } | 1580 | } |
1532 | 1581 | ||
1533 | #[test] | 1582 | #[test] |
1534 | fn infer_associated_method_with_modules() { | 1583 | fn infer_associated_method_with_modules() { |
1535 | assert_snapshot_matches!( | 1584 | assert_snapshot!( |
1536 | infer(r#" | 1585 | infer(r#" |
1537 | mod a { | 1586 | mod a { |
1538 | struct A; | 1587 | struct A; |
@@ -1557,28 +1606,30 @@ fn test() { | |||
1557 | } | 1606 | } |
1558 | "#), | 1607 | "#), |
1559 | @r###" | 1608 | @r###" |
1560 | [56; 64) '{ A {} }': A | 1609 | |
1561 | [58; 62) 'A {}': A | 1610 | [56; 64) '{ A {} }': A |
1562 | [126; 132) '{ 99 }': u32 | 1611 | [58; 62) 'A {}': A |
1563 | [128; 130) '99': u32 | 1612 | [126; 132) '{ 99 }': u32 |
1564 | [202; 210) '{ C {} }': C | 1613 | [128; 130) '99': u32 |
1565 | [204; 208) 'C {}': C | 1614 | [202; 210) '{ C {} }': C |
1566 | [241; 325) '{ ...g(); }': () | 1615 | [204; 208) 'C {}': C |
1567 | [251; 252) 'x': A | 1616 | [241; 325) '{ ...g(); }': () |
1568 | [255; 266) 'a::A::thing': fn thing() -> A | 1617 | [251; 252) 'x': A |
1569 | [255; 268) 'a::A::thing()': A | 1618 | [255; 266) 'a::A::thing': fn thing() -> A |
1570 | [278; 279) 'y': u32 | 1619 | [255; 268) 'a::A::thing()': A |
1571 | [282; 293) 'b::B::thing': fn thing() -> u32 | 1620 | [278; 279) 'y': u32 |
1572 | [282; 295) 'b::B::thing()': u32 | 1621 | [282; 293) 'b::B::thing': fn thing() -> u32 |
1573 | [305; 306) 'z': C | 1622 | [282; 295) 'b::B::thing()': u32 |
1574 | [309; 320) 'c::C::thing': fn thing() -> C | 1623 | [305; 306) 'z': C |
1575 | [309; 322) 'c::C::thing()': C"### | 1624 | [309; 320) 'c::C::thing': fn thing() -> C |
1625 | [309; 322) 'c::C::thing()': C | ||
1626 | "### | ||
1576 | ); | 1627 | ); |
1577 | } | 1628 | } |
1578 | 1629 | ||
1579 | #[test] | 1630 | #[test] |
1580 | fn infer_associated_method_generics() { | 1631 | fn infer_associated_method_generics() { |
1581 | assert_snapshot_matches!( | 1632 | assert_snapshot!( |
1582 | infer(r#" | 1633 | infer(r#" |
1583 | struct Gen<T> { | 1634 | struct Gen<T> { |
1584 | val: T | 1635 | val: T |
@@ -1595,21 +1646,23 @@ fn test() { | |||
1595 | } | 1646 | } |
1596 | "#), | 1647 | "#), |
1597 | @r###" | 1648 | @r###" |
1598 | [64; 67) 'val': T | 1649 | |
1599 | [82; 109) '{ ... }': Gen<T> | 1650 | [64; 67) 'val': T |
1600 | [92; 103) 'Gen { val }': Gen<T> | 1651 | [82; 109) '{ ... }': Gen<T> |
1601 | [98; 101) 'val': T | 1652 | [92; 103) 'Gen { val }': Gen<T> |
1602 | [123; 155) '{ ...32); }': () | 1653 | [98; 101) 'val': T |
1603 | [133; 134) 'a': Gen<u32> | 1654 | [123; 155) '{ ...32); }': () |
1604 | [137; 146) 'Gen::make': fn make<u32>(T) -> Gen<T> | 1655 | [133; 134) 'a': Gen<u32> |
1605 | [137; 152) 'Gen::make(0u32)': Gen<u32> | 1656 | [137; 146) 'Gen::make': fn make<u32>(T) -> Gen<T> |
1606 | [147; 151) '0u32': u32"### | 1657 | [137; 152) 'Gen::make(0u32)': Gen<u32> |
1658 | [147; 151) '0u32': u32 | ||
1659 | "### | ||
1607 | ); | 1660 | ); |
1608 | } | 1661 | } |
1609 | 1662 | ||
1610 | #[test] | 1663 | #[test] |
1611 | fn infer_associated_method_generics_with_default_param() { | 1664 | fn infer_associated_method_generics_with_default_param() { |
1612 | assert_snapshot_matches!( | 1665 | assert_snapshot!( |
1613 | infer(r#" | 1666 | infer(r#" |
1614 | struct Gen<T=u32> { | 1667 | struct Gen<T=u32> { |
1615 | val: T | 1668 | val: T |
@@ -1626,19 +1679,21 @@ fn test() { | |||
1626 | } | 1679 | } |
1627 | "#), | 1680 | "#), |
1628 | @r###" | 1681 | @r###" |
1629 | [80; 104) '{ ... }': ! | 1682 | |
1630 | [90; 98) 'loop { }': ! | 1683 | [80; 104) '{ ... }': ! |
1631 | [95; 98) '{ }': () | 1684 | [90; 98) 'loop { }': ! |
1632 | [118; 146) '{ ...e(); }': () | 1685 | [95; 98) '{ }': () |
1633 | [128; 129) 'a': Gen<u32> | 1686 | [118; 146) '{ ...e(); }': () |
1634 | [132; 141) 'Gen::make': fn make<u32>() -> Gen<T> | 1687 | [128; 129) 'a': Gen<u32> |
1635 | [132; 143) 'Gen::make()': Gen<u32>"### | 1688 | [132; 141) 'Gen::make': fn make<u32>() -> Gen<T> |
1689 | [132; 143) 'Gen::make()': Gen<u32> | ||
1690 | "### | ||
1636 | ); | 1691 | ); |
1637 | } | 1692 | } |
1638 | 1693 | ||
1639 | #[test] | 1694 | #[test] |
1640 | fn infer_associated_method_generics_without_args() { | 1695 | fn infer_associated_method_generics_without_args() { |
1641 | assert_snapshot_matches!( | 1696 | assert_snapshot!( |
1642 | infer(r#" | 1697 | infer(r#" |
1643 | struct Gen<T> { | 1698 | struct Gen<T> { |
1644 | val: T | 1699 | val: T |
@@ -1655,19 +1710,21 @@ fn test() { | |||
1655 | } | 1710 | } |
1656 | "#), | 1711 | "#), |
1657 | @r###" | 1712 | @r###" |
1658 | [76; 100) '{ ... }': ! | 1713 | |
1659 | [86; 94) 'loop { }': ! | 1714 | [76; 100) '{ ... }': ! |
1660 | [91; 94) '{ }': () | 1715 | [86; 94) 'loop { }': ! |
1661 | [114; 149) '{ ...e(); }': () | 1716 | [91; 94) '{ }': () |
1662 | [124; 125) 'a': Gen<u32> | 1717 | [114; 149) '{ ...e(); }': () |
1663 | [128; 144) 'Gen::<...::make': fn make<u32>() -> Gen<T> | 1718 | [124; 125) 'a': Gen<u32> |
1664 | [128; 146) 'Gen::<...make()': Gen<u32>"### | 1719 | [128; 144) 'Gen::<...::make': fn make<u32>() -> Gen<T> |
1720 | [128; 146) 'Gen::<...make()': Gen<u32> | ||
1721 | "### | ||
1665 | ); | 1722 | ); |
1666 | } | 1723 | } |
1667 | 1724 | ||
1668 | #[test] | 1725 | #[test] |
1669 | fn infer_associated_method_generics_2_type_params_without_args() { | 1726 | fn infer_associated_method_generics_2_type_params_without_args() { |
1670 | assert_snapshot_matches!( | 1727 | assert_snapshot!( |
1671 | infer(r#" | 1728 | infer(r#" |
1672 | struct Gen<T, U> { | 1729 | struct Gen<T, U> { |
1673 | val: T, | 1730 | val: T, |
@@ -1685,19 +1742,21 @@ fn test() { | |||
1685 | } | 1742 | } |
1686 | "#), | 1743 | "#), |
1687 | @r###" | 1744 | @r###" |
1688 | [102; 126) '{ ... }': ! | 1745 | |
1689 | [112; 120) 'loop { }': ! | 1746 | [102; 126) '{ ... }': ! |
1690 | [117; 120) '{ }': () | 1747 | [112; 120) 'loop { }': ! |
1691 | [140; 180) '{ ...e(); }': () | 1748 | [117; 120) '{ }': () |
1692 | [150; 151) 'a': Gen<u32, u64> | 1749 | [140; 180) '{ ...e(); }': () |
1693 | [154; 175) 'Gen::<...::make': fn make<u64>() -> Gen<u32, T> | 1750 | [150; 151) 'a': Gen<u32, u64> |
1694 | [154; 177) 'Gen::<...make()': Gen<u32, u64>"### | 1751 | [154; 175) 'Gen::<...::make': fn make<u64>() -> Gen<u32, T> |
1752 | [154; 177) 'Gen::<...make()': Gen<u32, u64> | ||
1753 | "### | ||
1695 | ); | 1754 | ); |
1696 | } | 1755 | } |
1697 | 1756 | ||
1698 | #[test] | 1757 | #[test] |
1699 | fn infer_type_alias() { | 1758 | fn infer_type_alias() { |
1700 | assert_snapshot_matches!( | 1759 | assert_snapshot!( |
1701 | infer(r#" | 1760 | infer(r#" |
1702 | struct A<X, Y> { x: X, y: Y } | 1761 | struct A<X, Y> { x: X, y: Y } |
1703 | type Foo = A<u32, i128>; | 1762 | type Foo = A<u32, i128>; |
@@ -1713,23 +1772,22 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) { | |||
1713 | } | 1772 | } |
1714 | "#), | 1773 | "#), |
1715 | @r###" | 1774 | @r###" |
1716 | ⋮ | 1775 | [116; 117) 'x': A<u32, i128> |
1717 | ⋮[116; 117) 'x': A<u32, i128> | 1776 | [124; 125) 'y': A<&str, u128> |
1718 | ⋮[124; 125) 'y': A<&str, u128> | 1777 | [138; 139) 'z': A<u8, i8> |
1719 | ⋮[138; 139) 'z': A<u8, i8> | 1778 | [154; 211) '{ ...z.y; }': () |
1720 | ⋮[154; 211) '{ ...z.y; }': () | 1779 | [160; 161) 'x': A<u32, i128> |
1721 | ⋮[160; 161) 'x': A<u32, i128> | 1780 | [160; 163) 'x.x': u32 |
1722 | ⋮[160; 163) 'x.x': u32 | 1781 | [169; 170) 'x': A<u32, i128> |
1723 | ⋮[169; 170) 'x': A<u32, i128> | 1782 | [169; 172) 'x.y': i128 |
1724 | ⋮[169; 172) 'x.y': i128 | 1783 | [178; 179) 'y': A<&str, u128> |
1725 | ⋮[178; 179) 'y': A<&str, u128> | 1784 | [178; 181) 'y.x': &str |
1726 | ⋮[178; 181) 'y.x': &str | 1785 | [187; 188) 'y': A<&str, u128> |
1727 | ⋮[187; 188) 'y': A<&str, u128> | 1786 | [187; 190) 'y.y': u128 |
1728 | ⋮[187; 190) 'y.y': u128 | 1787 | [196; 197) 'z': A<u8, i8> |
1729 | ⋮[196; 197) 'z': A<u8, i8> | 1788 | [196; 199) 'z.x': u8 |
1730 | ⋮[196; 199) 'z.x': u8 | 1789 | [205; 206) 'z': A<u8, i8> |
1731 | ⋮[205; 206) 'z': A<u8, i8> | 1790 | [205; 208) 'z.y': i8 |
1732 | ⋮[205; 208) 'z.y': i8 | ||
1733 | "### | 1791 | "### |
1734 | ) | 1792 | ) |
1735 | } | 1793 | } |
@@ -1737,7 +1795,7 @@ fn test(x: Foo, y: Bar<&str>, z: Baz<i8, u8>) { | |||
1737 | #[test] | 1795 | #[test] |
1738 | #[should_panic] // we currently can't handle this | 1796 | #[should_panic] // we currently can't handle this |
1739 | fn recursive_type_alias() { | 1797 | fn recursive_type_alias() { |
1740 | assert_snapshot_matches!( | 1798 | assert_snapshot!( |
1741 | infer(r#" | 1799 | infer(r#" |
1742 | struct A<X> {} | 1800 | struct A<X> {} |
1743 | type Foo = Foo; | 1801 | type Foo = Foo; |
@@ -1750,7 +1808,7 @@ fn test(x: Foo) {} | |||
1750 | 1808 | ||
1751 | #[test] | 1809 | #[test] |
1752 | fn no_panic_on_field_of_enum() { | 1810 | fn no_panic_on_field_of_enum() { |
1753 | assert_snapshot_matches!( | 1811 | assert_snapshot!( |
1754 | infer(r#" | 1812 | infer(r#" |
1755 | enum X {} | 1813 | enum X {} |
1756 | 1814 | ||
@@ -1759,16 +1817,18 @@ fn test(x: X) { | |||
1759 | } | 1817 | } |
1760 | "#), | 1818 | "#), |
1761 | @r###" | 1819 | @r###" |
1762 | [20; 21) 'x': X | 1820 | |
1763 | [26; 47) '{ ...eld; }': () | 1821 | [20; 21) 'x': X |
1764 | [32; 33) 'x': X | 1822 | [26; 47) '{ ...eld; }': () |
1765 | [32; 44) 'x.some_field': {unknown}"### | 1823 | [32; 33) 'x': X |
1824 | [32; 44) 'x.some_field': {unknown} | ||
1825 | "### | ||
1766 | ); | 1826 | ); |
1767 | } | 1827 | } |
1768 | 1828 | ||
1769 | #[test] | 1829 | #[test] |
1770 | fn bug_585() { | 1830 | fn bug_585() { |
1771 | assert_snapshot_matches!( | 1831 | assert_snapshot!( |
1772 | infer(r#" | 1832 | infer(r#" |
1773 | fn test() { | 1833 | fn test() { |
1774 | X {}; | 1834 | X {}; |
@@ -1779,20 +1839,22 @@ fn test() { | |||
1779 | } | 1839 | } |
1780 | "#), | 1840 | "#), |
1781 | @r###" | 1841 | @r###" |
1782 | [11; 89) '{ ... } }': () | 1842 | |
1783 | [17; 21) 'X {}': {unknown} | 1843 | [11; 89) '{ ... } }': () |
1784 | [27; 87) 'match ... }': () | 1844 | [17; 21) 'X {}': {unknown} |
1785 | [33; 34) 'x': {unknown} | 1845 | [27; 87) 'match ... }': () |
1786 | [45; 52) 'A::B {}': {unknown} | 1846 | [33; 34) 'x': {unknown} |
1787 | [56; 58) '()': () | 1847 | [45; 52) 'A::B {}': {unknown} |
1788 | [68; 74) 'A::Y()': {unknown} | 1848 | [56; 58) '()': () |
1789 | [78; 80) '()': ()"### | 1849 | [68; 74) 'A::Y()': {unknown} |
1850 | [78; 80) '()': () | ||
1851 | "### | ||
1790 | ); | 1852 | ); |
1791 | } | 1853 | } |
1792 | 1854 | ||
1793 | #[test] | 1855 | #[test] |
1794 | fn bug_651() { | 1856 | fn bug_651() { |
1795 | assert_snapshot_matches!( | 1857 | assert_snapshot!( |
1796 | infer(r#" | 1858 | infer(r#" |
1797 | fn quux() { | 1859 | fn quux() { |
1798 | let y = 92; | 1860 | let y = 92; |
@@ -1800,12 +1862,14 @@ fn quux() { | |||
1800 | } | 1862 | } |
1801 | "#), | 1863 | "#), |
1802 | @r###" | 1864 | @r###" |
1803 | [11; 41) '{ ...+ y; }': () | 1865 | |
1804 | [21; 22) 'y': i32 | 1866 | [11; 41) '{ ...+ y; }': () |
1805 | [25; 27) '92': i32 | 1867 | [21; 22) 'y': i32 |
1806 | [33; 34) '1': i32 | 1868 | [25; 27) '92': i32 |
1807 | [33; 38) '1 + y': i32 | 1869 | [33; 34) '1': i32 |
1808 | [37; 38) 'y': i32"### | 1870 | [33; 38) '1 + y': i32 |
1871 | [37; 38) 'y': i32 | ||
1872 | "### | ||
1809 | ); | 1873 | ); |
1810 | } | 1874 | } |
1811 | 1875 | ||
@@ -1813,7 +1877,7 @@ fn quux() { | |||
1813 | fn recursive_vars() { | 1877 | fn recursive_vars() { |
1814 | covers!(type_var_cycles_resolve_completely); | 1878 | covers!(type_var_cycles_resolve_completely); |
1815 | covers!(type_var_cycles_resolve_as_possible); | 1879 | covers!(type_var_cycles_resolve_as_possible); |
1816 | assert_snapshot_matches!( | 1880 | assert_snapshot!( |
1817 | infer(r#" | 1881 | infer(r#" |
1818 | fn test() { | 1882 | fn test() { |
1819 | let y = unknown; | 1883 | let y = unknown; |
@@ -1821,13 +1885,15 @@ fn test() { | |||
1821 | } | 1885 | } |
1822 | "#), | 1886 | "#), |
1823 | @r###" | 1887 | @r###" |
1824 | [11; 48) '{ ...&y]; }': () | 1888 | |
1825 | [21; 22) 'y': &{unknown} | 1889 | [11; 48) '{ ...&y]; }': () |
1826 | [25; 32) 'unknown': &{unknown} | 1890 | [21; 22) 'y': &{unknown} |
1827 | [38; 45) '[y, &y]': [&&{unknown};_] | 1891 | [25; 32) 'unknown': &{unknown} |
1828 | [39; 40) 'y': &{unknown} | 1892 | [38; 45) '[y, &y]': [&&{unknown};_] |
1829 | [42; 44) '&y': &&{unknown} | 1893 | [39; 40) 'y': &{unknown} |
1830 | [43; 44) 'y': &{unknown}"### | 1894 | [42; 44) '&y': &&{unknown} |
1895 | [43; 44) 'y': &{unknown} | ||
1896 | "### | ||
1831 | ); | 1897 | ); |
1832 | } | 1898 | } |
1833 | 1899 | ||
@@ -1835,7 +1901,7 @@ fn test() { | |||
1835 | fn recursive_vars_2() { | 1901 | fn recursive_vars_2() { |
1836 | covers!(type_var_cycles_resolve_completely); | 1902 | covers!(type_var_cycles_resolve_completely); |
1837 | covers!(type_var_cycles_resolve_as_possible); | 1903 | covers!(type_var_cycles_resolve_as_possible); |
1838 | assert_snapshot_matches!( | 1904 | assert_snapshot!( |
1839 | infer(r#" | 1905 | infer(r#" |
1840 | fn test() { | 1906 | fn test() { |
1841 | let x = unknown; | 1907 | let x = unknown; |
@@ -1844,26 +1910,28 @@ fn test() { | |||
1844 | } | 1910 | } |
1845 | "#), | 1911 | "#), |
1846 | @r###" | 1912 | @r###" |
1847 | [11; 80) '{ ...x)]; }': () | 1913 | |
1848 | [21; 22) 'x': &&{unknown} | 1914 | [11; 80) '{ ...x)]; }': () |
1849 | [25; 32) 'unknown': &&{unknown} | 1915 | [21; 22) 'x': &&{unknown} |
1850 | [42; 43) 'y': &&{unknown} | 1916 | [25; 32) 'unknown': &&{unknown} |
1851 | [46; 53) 'unknown': &&{unknown} | 1917 | [42; 43) 'y': &&{unknown} |
1852 | [59; 77) '[(x, y..., &x)]': [(&&{unknown}, &&{unknown});_] | 1918 | [46; 53) 'unknown': &&{unknown} |
1853 | [60; 66) '(x, y)': (&&{unknown}, &&{unknown}) | 1919 | [59; 77) '[(x, y..., &x)]': [(&&{unknown}, &&{unknown});_] |
1854 | [61; 62) 'x': &&{unknown} | 1920 | [60; 66) '(x, y)': (&&{unknown}, &&{unknown}) |
1855 | [64; 65) 'y': &&{unknown} | 1921 | [61; 62) 'x': &&{unknown} |
1856 | [68; 76) '(&y, &x)': (&&&{unknown}, &&&{unknown}) | 1922 | [64; 65) 'y': &&{unknown} |
1857 | [69; 71) '&y': &&&{unknown} | 1923 | [68; 76) '(&y, &x)': (&&&{unknown}, &&&{unknown}) |
1858 | [70; 71) 'y': &&{unknown} | 1924 | [69; 71) '&y': &&&{unknown} |
1859 | [73; 75) '&x': &&&{unknown} | 1925 | [70; 71) 'y': &&{unknown} |
1860 | [74; 75) 'x': &&{unknown}"### | 1926 | [73; 75) '&x': &&&{unknown} |
1927 | [74; 75) 'x': &&{unknown} | ||
1928 | "### | ||
1861 | ); | 1929 | ); |
1862 | } | 1930 | } |
1863 | 1931 | ||
1864 | #[test] | 1932 | #[test] |
1865 | fn infer_type_param() { | 1933 | fn infer_type_param() { |
1866 | assert_snapshot_matches!( | 1934 | assert_snapshot!( |
1867 | infer(r#" | 1935 | infer(r#" |
1868 | fn id<T>(x: T) -> T { | 1936 | fn id<T>(x: T) -> T { |
1869 | x | 1937 | x |
@@ -1881,32 +1949,34 @@ fn test() { | |||
1881 | } | 1949 | } |
1882 | "#), | 1950 | "#), |
1883 | @r###" | 1951 | @r###" |
1884 | [10; 11) 'x': T | 1952 | |
1885 | [21; 30) '{ x }': T | 1953 | [10; 11) 'x': T |
1886 | [27; 28) 'x': T | 1954 | [21; 30) '{ x }': T |
1887 | [44; 45) 'x': &T | 1955 | [27; 28) 'x': T |
1888 | [56; 65) '{ x }': &T | 1956 | [44; 45) 'x': &T |
1889 | [62; 63) 'x': &T | 1957 | [56; 65) '{ x }': &T |
1890 | [77; 157) '{ ...(1); }': () | 1958 | [62; 63) 'x': &T |
1891 | [87; 88) 'y': u32 | 1959 | [77; 157) '{ ...(1); }': () |
1892 | [91; 96) '10u32': u32 | 1960 | [87; 88) 'y': u32 |
1893 | [102; 104) 'id': fn id<u32>(T) -> T | 1961 | [91; 96) '10u32': u32 |
1894 | [102; 107) 'id(y)': u32 | 1962 | [102; 104) 'id': fn id<u32>(T) -> T |
1895 | [105; 106) 'y': u32 | 1963 | [102; 107) 'id(y)': u32 |
1896 | [117; 118) 'x': bool | 1964 | [105; 106) 'y': u32 |
1897 | [127; 132) 'clone': fn clone<bool>(&T) -> T | 1965 | [117; 118) 'x': bool |
1898 | [127; 135) 'clone(z)': bool | 1966 | [127; 132) 'clone': fn clone<bool>(&T) -> T |
1899 | [133; 134) 'z': &bool | 1967 | [127; 135) 'clone(z)': bool |
1900 | [141; 151) 'id::<i128>': fn id<i128>(T) -> T | 1968 | [133; 134) 'z': &bool |
1901 | [141; 154) 'id::<i128>(1)': i128 | 1969 | [141; 151) 'id::<i128>': fn id<i128>(T) -> T |
1902 | [152; 153) '1': i128"### | 1970 | [141; 154) 'id::<i128>(1)': i128 |
1971 | [152; 153) '1': i128 | ||
1972 | "### | ||
1903 | ); | 1973 | ); |
1904 | } | 1974 | } |
1905 | 1975 | ||
1906 | #[test] | 1976 | #[test] |
1907 | fn infer_std_crash_1() { | 1977 | fn infer_std_crash_1() { |
1908 | // caused stack overflow, taken from std | 1978 | // caused stack overflow, taken from std |
1909 | assert_snapshot_matches!( | 1979 | assert_snapshot!( |
1910 | infer(r#" | 1980 | infer(r#" |
1911 | enum Maybe<T> { | 1981 | enum Maybe<T> { |
1912 | Real(T), | 1982 | Real(T), |
@@ -1920,12 +1990,14 @@ fn write() { | |||
1920 | } | 1990 | } |
1921 | "#), | 1991 | "#), |
1922 | @r###" | 1992 | @r###" |
1923 | [54; 139) '{ ... } }': () | 1993 | |
1924 | [60; 137) 'match ... }': () | 1994 | [54; 139) '{ ... } }': () |
1925 | [66; 83) 'someth...nknown': Maybe<{unknown}> | 1995 | [60; 137) 'match ... }': () |
1926 | [94; 124) 'Maybe:...thing)': Maybe<{unknown}> | 1996 | [66; 83) 'someth...nknown': Maybe<{unknown}> |
1927 | [106; 123) 'ref mu...ething': &mut {unknown} | 1997 | [94; 124) 'Maybe:...thing)': Maybe<{unknown}> |
1928 | [128; 130) '()': ()"### | 1998 | [106; 123) 'ref mu...ething': &mut {unknown} |
1999 | [128; 130) '()': () | ||
2000 | "### | ||
1929 | ); | 2001 | ); |
1930 | } | 2002 | } |
1931 | 2003 | ||
@@ -1933,27 +2005,29 @@ fn write() { | |||
1933 | fn infer_std_crash_2() { | 2005 | fn infer_std_crash_2() { |
1934 | covers!(type_var_resolves_to_int_var); | 2006 | covers!(type_var_resolves_to_int_var); |
1935 | // caused "equating two type variables, ...", taken from std | 2007 | // caused "equating two type variables, ...", taken from std |
1936 | assert_snapshot_matches!( | 2008 | assert_snapshot!( |
1937 | infer(r#" | 2009 | infer(r#" |
1938 | fn test_line_buffer() { | 2010 | fn test_line_buffer() { |
1939 | &[0, b'\n', 1, b'\n']; | 2011 | &[0, b'\n', 1, b'\n']; |
1940 | } | 2012 | } |
1941 | "#), | 2013 | "#), |
1942 | @r###" | 2014 | @r###" |
1943 | [23; 53) '{ ...n']; }': () | 2015 | |
1944 | [29; 50) '&[0, b...b'\n']': &[u8;_] | 2016 | [23; 53) '{ ...n']; }': () |
1945 | [30; 50) '[0, b'...b'\n']': [u8;_] | 2017 | [29; 50) '&[0, b...b'\n']': &[u8;_] |
1946 | [31; 32) '0': u8 | 2018 | [30; 50) '[0, b'...b'\n']': [u8;_] |
1947 | [34; 39) 'b'\n'': u8 | 2019 | [31; 32) '0': u8 |
1948 | [41; 42) '1': u8 | 2020 | [34; 39) 'b'\n'': u8 |
1949 | [44; 49) 'b'\n'': u8"### | 2021 | [41; 42) '1': u8 |
2022 | [44; 49) 'b'\n'': u8 | ||
2023 | "### | ||
1950 | ); | 2024 | ); |
1951 | } | 2025 | } |
1952 | 2026 | ||
1953 | #[test] | 2027 | #[test] |
1954 | fn infer_std_crash_3() { | 2028 | fn infer_std_crash_3() { |
1955 | // taken from rustc | 2029 | // taken from rustc |
1956 | assert_snapshot_matches!( | 2030 | assert_snapshot!( |
1957 | infer(r#" | 2031 | infer(r#" |
1958 | pub fn compute() { | 2032 | pub fn compute() { |
1959 | match nope!() { | 2033 | match nope!() { |
@@ -1962,14 +2036,13 @@ pub fn compute() { | |||
1962 | } | 2036 | } |
1963 | "#), | 2037 | "#), |
1964 | @r###" | 2038 | @r###" |
1965 | ⋮ | 2039 | [18; 108) '{ ... } }': () |
1966 | ⋮[18; 108) '{ ... } }': () | 2040 | [24; 106) 'match ... }': () |
1967 | ⋮[24; 106) 'match ... }': () | 2041 | [30; 37) 'nope!()': {unknown} |
1968 | ⋮[30; 37) 'nope!()': {unknown} | 2042 | [48; 94) 'SizeSk...tail }': {unknown} |
1969 | ⋮[48; 94) 'SizeSk...tail }': {unknown} | 2043 | [82; 86) 'true': {unknown} |
1970 | ⋮[82; 86) 'true': {unknown} | 2044 | [88; 92) 'tail': {unknown} |
1971 | ⋮[88; 92) 'tail': {unknown} | 2045 | [98; 100) '{}': () |
1972 | ⋮[98; 100) '{}': () | ||
1973 | "### | 2046 | "### |
1974 | ); | 2047 | ); |
1975 | } | 2048 | } |
@@ -1977,7 +2050,7 @@ pub fn compute() { | |||
1977 | #[test] | 2050 | #[test] |
1978 | fn infer_std_crash_4() { | 2051 | fn infer_std_crash_4() { |
1979 | // taken from rustc | 2052 | // taken from rustc |
1980 | assert_snapshot_matches!( | 2053 | assert_snapshot!( |
1981 | infer(r#" | 2054 | infer(r#" |
1982 | pub fn primitive_type() { | 2055 | pub fn primitive_type() { |
1983 | match *self { | 2056 | match *self { |
@@ -1986,15 +2059,14 @@ pub fn primitive_type() { | |||
1986 | } | 2059 | } |
1987 | "#), | 2060 | "#), |
1988 | @r###" | 2061 | @r###" |
1989 | ⋮ | 2062 | [25; 106) '{ ... } }': () |
1990 | ⋮[25; 106) '{ ... } }': () | 2063 | [31; 104) 'match ... }': () |
1991 | ⋮[31; 104) 'match ... }': () | 2064 | [37; 42) '*self': {unknown} |
1992 | ⋮[37; 42) '*self': {unknown} | 2065 | [38; 42) 'self': {unknown} |
1993 | ⋮[38; 42) 'self': {unknown} | 2066 | [53; 91) 'Borrow...), ..}': {unknown} |
1994 | ⋮[53; 91) 'Borrow...), ..}': {unknown} | 2067 | [74; 86) 'Primitive(p)': {unknown} |
1995 | ⋮[74; 86) 'Primitive(p)': {unknown} | 2068 | [84; 85) 'p': {unknown} |
1996 | ⋮[84; 85) 'p': {unknown} | 2069 | [95; 97) '{}': () |
1997 | ⋮[95; 97) '{}': () | ||
1998 | "### | 2070 | "### |
1999 | ); | 2071 | ); |
2000 | } | 2072 | } |
@@ -2002,7 +2074,7 @@ pub fn primitive_type() { | |||
2002 | #[test] | 2074 | #[test] |
2003 | fn infer_std_crash_5() { | 2075 | fn infer_std_crash_5() { |
2004 | // taken from rustc | 2076 | // taken from rustc |
2005 | assert_snapshot_matches!( | 2077 | assert_snapshot!( |
2006 | infer(r#" | 2078 | infer(r#" |
2007 | fn extra_compiler_flags() { | 2079 | fn extra_compiler_flags() { |
2008 | for content in doesnt_matter { | 2080 | for content in doesnt_matter { |
@@ -2021,36 +2093,38 @@ fn extra_compiler_flags() { | |||
2021 | } | 2093 | } |
2022 | "#), | 2094 | "#), |
2023 | @r###" | 2095 | @r###" |
2024 | [27; 323) '{ ... } }': () | 2096 | |
2025 | [33; 321) 'for co... }': () | 2097 | [27; 323) '{ ... } }': () |
2026 | [37; 44) 'content': &{unknown} | 2098 | [33; 321) 'for co... }': () |
2027 | [48; 61) 'doesnt_matter': {unknown} | 2099 | [37; 44) 'content': &{unknown} |
2028 | [62; 321) '{ ... }': () | 2100 | [48; 61) 'doesnt_matter': {unknown} |
2029 | [76; 80) 'name': &&{unknown} | 2101 | [62; 321) '{ ... }': () |
2030 | [83; 167) 'if doe... }': &&{unknown} | 2102 | [76; 80) 'name': &&{unknown} |
2031 | [86; 99) 'doesnt_matter': bool | 2103 | [83; 167) 'if doe... }': &&{unknown} |
2032 | [100; 129) '{ ... }': &&{unknown} | 2104 | [86; 99) 'doesnt_matter': bool |
2033 | [114; 119) 'first': &&{unknown} | 2105 | [100; 129) '{ ... }': &&{unknown} |
2034 | [135; 167) '{ ... }': &&{unknown} | 2106 | [114; 119) 'first': &&{unknown} |
2035 | [149; 157) '&content': &&{unknown} | 2107 | [135; 167) '{ ... }': &&{unknown} |
2036 | [150; 157) 'content': &{unknown} | 2108 | [149; 157) '&content': &&{unknown} |
2037 | [182; 189) 'content': &&{unknown} | 2109 | [150; 157) 'content': &{unknown} |
2038 | [192; 314) 'if ICE... }': &&{unknown} | 2110 | [182; 189) 'content': &&{unknown} |
2039 | [195; 232) 'ICE_RE..._VALUE': {unknown} | 2111 | [192; 314) 'if ICE... }': &&{unknown} |
2040 | [195; 248) 'ICE_RE...&name)': bool | 2112 | [195; 232) 'ICE_RE..._VALUE': {unknown} |
2041 | [242; 247) '&name': &&&{unknown} | 2113 | [195; 248) 'ICE_RE...&name)': bool |
2042 | [243; 247) 'name': &&{unknown} | 2114 | [242; 247) '&name': &&&{unknown} |
2043 | [249; 277) '{ ... }': &&{unknown} | 2115 | [243; 247) 'name': &&{unknown} |
2044 | [263; 267) 'name': &&{unknown} | 2116 | [249; 277) '{ ... }': &&{unknown} |
2045 | [283; 314) '{ ... }': &{unknown} | 2117 | [263; 267) 'name': &&{unknown} |
2046 | [297; 304) 'content': &{unknown}"### | 2118 | [283; 314) '{ ... }': &{unknown} |
2119 | [297; 304) 'content': &{unknown} | ||
2120 | "### | ||
2047 | ); | 2121 | ); |
2048 | } | 2122 | } |
2049 | 2123 | ||
2050 | #[test] | 2124 | #[test] |
2051 | fn infer_nested_generics_crash() { | 2125 | fn infer_nested_generics_crash() { |
2052 | // another crash found typechecking rustc | 2126 | // another crash found typechecking rustc |
2053 | assert_snapshot_matches!( | 2127 | assert_snapshot!( |
2054 | infer(r#" | 2128 | infer(r#" |
2055 | struct Canonical<V> { | 2129 | struct Canonical<V> { |
2056 | value: V, | 2130 | value: V, |
@@ -2063,17 +2137,19 @@ fn test<R>(query_response: Canonical<QueryResponse<R>>) { | |||
2063 | } | 2137 | } |
2064 | "#), | 2138 | "#), |
2065 | @r###" | 2139 | @r###" |
2066 | [92; 106) 'query_response': Canonical<QueryResponse<R>> | 2140 | |
2067 | [137; 167) '{ ...lue; }': () | 2141 | [92; 106) 'query_response': Canonical<QueryResponse<R>> |
2068 | [143; 164) '&query....value': &QueryResponse<R> | 2142 | [137; 167) '{ ...lue; }': () |
2069 | [144; 158) 'query_response': Canonical<QueryResponse<R>> | 2143 | [143; 164) '&query....value': &QueryResponse<R> |
2070 | [144; 164) 'query_....value': QueryResponse<R>"### | 2144 | [144; 158) 'query_response': Canonical<QueryResponse<R>> |
2145 | [144; 164) 'query_....value': QueryResponse<R> | ||
2146 | "### | ||
2071 | ); | 2147 | ); |
2072 | } | 2148 | } |
2073 | 2149 | ||
2074 | #[test] | 2150 | #[test] |
2075 | fn bug_1030() { | 2151 | fn bug_1030() { |
2076 | assert_snapshot_matches!(infer(r#" | 2152 | assert_snapshot!(infer(r#" |
2077 | struct HashSet<T, H>; | 2153 | struct HashSet<T, H>; |
2078 | struct FxHasher; | 2154 | struct FxHasher; |
2079 | type FxHashSet<T> = HashSet<T, FxHasher>; | 2155 | type FxHashSet<T> = HashSet<T, FxHasher>; |
@@ -2087,10 +2163,12 @@ pub fn main_loop() { | |||
2087 | } | 2163 | } |
2088 | "#), | 2164 | "#), |
2089 | @r###" | 2165 | @r###" |
2090 | [144; 146) '{}': () | 2166 | |
2091 | [169; 198) '{ ...t(); }': () | 2167 | [144; 146) '{}': () |
2092 | [175; 193) 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<T, H> | 2168 | [169; 198) '{ ...t(); }': () |
2093 | [175; 195) 'FxHash...ault()': HashSet<{unknown}, FxHasher>"### | 2169 | [175; 193) 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<T, H> |
2170 | [175; 195) 'FxHash...ault()': HashSet<{unknown}, FxHasher> | ||
2171 | "### | ||
2094 | ); | 2172 | ); |
2095 | } | 2173 | } |
2096 | 2174 | ||
@@ -2122,7 +2200,7 @@ mod foo { | |||
2122 | 2200 | ||
2123 | #[test] | 2201 | #[test] |
2124 | fn infer_const() { | 2202 | fn infer_const() { |
2125 | assert_snapshot_matches!( | 2203 | assert_snapshot!( |
2126 | infer(r#" | 2204 | infer(r#" |
2127 | struct Foo; | 2205 | struct Foo; |
2128 | impl Foo { const ASSOC_CONST: u32 = 0; } | 2206 | impl Foo { const ASSOC_CONST: u32 = 0; } |
@@ -2135,22 +2213,24 @@ fn test() { | |||
2135 | } | 2213 | } |
2136 | "#), | 2214 | "#), |
2137 | @r###" | 2215 | @r###" |
2138 | [49; 50) '0': u32 | 2216 | |
2139 | [80; 83) '101': u32 | 2217 | [49; 50) '0': u32 |
2140 | [95; 213) '{ ...NST; }': () | 2218 | [80; 83) '101': u32 |
2141 | [138; 139) 'x': {unknown} | 2219 | [95; 213) '{ ...NST; }': () |
2142 | [142; 153) 'LOCAL_CONST': {unknown} | 2220 | [138; 139) 'x': {unknown} |
2143 | [163; 164) 'z': u32 | 2221 | [142; 153) 'LOCAL_CONST': {unknown} |
2144 | [167; 179) 'GLOBAL_CONST': u32 | 2222 | [163; 164) 'z': u32 |
2145 | [189; 191) 'id': u32 | 2223 | [167; 179) 'GLOBAL_CONST': u32 |
2146 | [194; 210) 'Foo::A..._CONST': u32 | 2224 | [189; 191) 'id': u32 |
2147 | [126; 128) '99': u32"### | 2225 | [194; 210) 'Foo::A..._CONST': u32 |
2226 | [126; 128) '99': u32 | ||
2227 | "### | ||
2148 | ); | 2228 | ); |
2149 | } | 2229 | } |
2150 | 2230 | ||
2151 | #[test] | 2231 | #[test] |
2152 | fn infer_static() { | 2232 | fn infer_static() { |
2153 | assert_snapshot_matches!( | 2233 | assert_snapshot!( |
2154 | infer(r#" | 2234 | infer(r#" |
2155 | static GLOBAL_STATIC: u32 = 101; | 2235 | static GLOBAL_STATIC: u32 = 101; |
2156 | static mut GLOBAL_STATIC_MUT: u32 = 101; | 2236 | static mut GLOBAL_STATIC_MUT: u32 = 101; |
@@ -2164,26 +2244,28 @@ fn test() { | |||
2164 | } | 2244 | } |
2165 | "#), | 2245 | "#), |
2166 | @r###" | 2246 | @r###" |
2167 | [29; 32) '101': u32 | 2247 | |
2168 | [70; 73) '101': u32 | 2248 | [29; 32) '101': u32 |
2169 | [85; 280) '{ ...MUT; }': () | 2249 | [70; 73) '101': u32 |
2170 | [173; 174) 'x': {unknown} | 2250 | [85; 280) '{ ...MUT; }': () |
2171 | [177; 189) 'LOCAL_STATIC': {unknown} | 2251 | [173; 174) 'x': {unknown} |
2172 | [199; 200) 'y': {unknown} | 2252 | [177; 189) 'LOCAL_STATIC': {unknown} |
2173 | [203; 219) 'LOCAL_...IC_MUT': {unknown} | 2253 | [199; 200) 'y': {unknown} |
2174 | [229; 230) 'z': u32 | 2254 | [203; 219) 'LOCAL_...IC_MUT': {unknown} |
2175 | [233; 246) 'GLOBAL_STATIC': u32 | 2255 | [229; 230) 'z': u32 |
2176 | [256; 257) 'w': u32 | 2256 | [233; 246) 'GLOBAL_STATIC': u32 |
2177 | [260; 277) 'GLOBAL...IC_MUT': u32 | 2257 | [256; 257) 'w': u32 |
2178 | [118; 120) '99': u32 | 2258 | [260; 277) 'GLOBAL...IC_MUT': u32 |
2179 | [161; 163) '99': u32"### | 2259 | [118; 120) '99': u32 |
2260 | [161; 163) '99': u32 | ||
2261 | "### | ||
2180 | ); | 2262 | ); |
2181 | } | 2263 | } |
2182 | 2264 | ||
2183 | #[test] | 2265 | #[test] |
2184 | fn infer_trait_method_simple() { | 2266 | fn infer_trait_method_simple() { |
2185 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 2267 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
2186 | assert_snapshot_matches!( | 2268 | assert_snapshot!( |
2187 | infer(r#" | 2269 | infer(r#" |
2188 | trait Trait1 { | 2270 | trait Trait1 { |
2189 | fn method(&self) -> u32; | 2271 | fn method(&self) -> u32; |
@@ -2201,20 +2283,22 @@ fn test() { | |||
2201 | } | 2283 | } |
2202 | "#), | 2284 | "#), |
2203 | @r###" | 2285 | @r###" |
2204 | [31; 35) 'self': &Self | 2286 | |
2205 | [110; 114) 'self': &Self | 2287 | [31; 35) 'self': &Self |
2206 | [170; 228) '{ ...i128 }': () | 2288 | [110; 114) 'self': &Self |
2207 | [176; 178) 'S1': S1 | 2289 | [170; 228) '{ ...i128 }': () |
2208 | [176; 187) 'S1.method()': u32 | 2290 | [176; 178) 'S1': S1 |
2209 | [203; 205) 'S2': S2 | 2291 | [176; 187) 'S1.method()': u32 |
2210 | [203; 214) 'S2.method()': i128"### | 2292 | [203; 205) 'S2': S2 |
2293 | [203; 214) 'S2.method()': i128 | ||
2294 | "### | ||
2211 | ); | 2295 | ); |
2212 | } | 2296 | } |
2213 | 2297 | ||
2214 | #[test] | 2298 | #[test] |
2215 | fn infer_trait_method_scoped() { | 2299 | fn infer_trait_method_scoped() { |
2216 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 2300 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
2217 | assert_snapshot_matches!( | 2301 | assert_snapshot!( |
2218 | infer(r#" | 2302 | infer(r#" |
2219 | struct S; | 2303 | struct S; |
2220 | mod foo { | 2304 | mod foo { |
@@ -2247,21 +2331,23 @@ mod bar_test { | |||
2247 | } | 2331 | } |
2248 | "#), | 2332 | "#), |
2249 | @r###" | 2333 | @r###" |
2250 | [63; 67) 'self': &Self | 2334 | |
2251 | [169; 173) 'self': &Self | 2335 | [63; 67) 'self': &Self |
2252 | [300; 337) '{ ... }': () | 2336 | [169; 173) 'self': &Self |
2253 | [310; 311) 'S': S | 2337 | [300; 337) '{ ... }': () |
2254 | [310; 320) 'S.method()': u32 | 2338 | [310; 311) 'S': S |
2255 | [416; 454) '{ ... }': () | 2339 | [310; 320) 'S.method()': u32 |
2256 | [426; 427) 'S': S | 2340 | [416; 454) '{ ... }': () |
2257 | [426; 436) 'S.method()': i128"### | 2341 | [426; 427) 'S': S |
2342 | [426; 436) 'S.method()': i128 | ||
2343 | "### | ||
2258 | ); | 2344 | ); |
2259 | } | 2345 | } |
2260 | 2346 | ||
2261 | #[test] | 2347 | #[test] |
2262 | fn infer_trait_method_generic_1() { | 2348 | fn infer_trait_method_generic_1() { |
2263 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 2349 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
2264 | assert_snapshot_matches!( | 2350 | assert_snapshot!( |
2265 | infer(r#" | 2351 | infer(r#" |
2266 | trait Trait<T> { | 2352 | trait Trait<T> { |
2267 | fn method(&self) -> T; | 2353 | fn method(&self) -> T; |
@@ -2273,17 +2359,19 @@ fn test() { | |||
2273 | } | 2359 | } |
2274 | "#), | 2360 | "#), |
2275 | @r###" | 2361 | @r###" |
2276 | [33; 37) 'self': &Self | 2362 | |
2277 | [92; 111) '{ ...d(); }': () | 2363 | [33; 37) 'self': &Self |
2278 | [98; 99) 'S': S | 2364 | [92; 111) '{ ...d(); }': () |
2279 | [98; 108) 'S.method()': u32"### | 2365 | [98; 99) 'S': S |
2366 | [98; 108) 'S.method()': u32 | ||
2367 | "### | ||
2280 | ); | 2368 | ); |
2281 | } | 2369 | } |
2282 | 2370 | ||
2283 | #[test] | 2371 | #[test] |
2284 | fn infer_trait_method_generic_more_params() { | 2372 | fn infer_trait_method_generic_more_params() { |
2285 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 2373 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
2286 | assert_snapshot_matches!( | 2374 | assert_snapshot!( |
2287 | infer(r#" | 2375 | infer(r#" |
2288 | trait Trait<T1, T2, T3> { | 2376 | trait Trait<T1, T2, T3> { |
2289 | fn method1(&self) -> (T1, T2, T3); | 2377 | fn method1(&self) -> (T1, T2, T3); |
@@ -2301,24 +2389,26 @@ fn test() { | |||
2301 | } | 2389 | } |
2302 | "#), | 2390 | "#), |
2303 | @r###" | 2391 | @r###" |
2304 | [43; 47) 'self': &Self | 2392 | |
2305 | [82; 86) 'self': &Self | 2393 | [43; 47) 'self': &Self |
2306 | [210; 361) '{ ..., i8 }': () | 2394 | [82; 86) 'self': &Self |
2307 | [216; 218) 'S1': S1 | 2395 | [210; 361) '{ ..., i8 }': () |
2308 | [216; 228) 'S1.method1()': (u8, u16, u32) | 2396 | [216; 218) 'S1': S1 |
2309 | [250; 252) 'S1': S1 | 2397 | [216; 228) 'S1.method1()': (u8, u16, u32) |
2310 | [250; 262) 'S1.method2()': (u32, u16, u8) | 2398 | [250; 252) 'S1': S1 |
2311 | [284; 286) 'S2': S2 | 2399 | [250; 262) 'S1.method2()': (u32, u16, u8) |
2312 | [284; 296) 'S2.method1()': (i8, i16, {unknown}) | 2400 | [284; 286) 'S2': S2 |
2313 | [324; 326) 'S2': S2 | 2401 | [284; 296) 'S2.method1()': (i8, i16, {unknown}) |
2314 | [324; 336) 'S2.method2()': ({unknown}, i16, i8)"### | 2402 | [324; 326) 'S2': S2 |
2403 | [324; 336) 'S2.method2()': ({unknown}, i16, i8) | ||
2404 | "### | ||
2315 | ); | 2405 | ); |
2316 | } | 2406 | } |
2317 | 2407 | ||
2318 | #[test] | 2408 | #[test] |
2319 | fn infer_trait_method_generic_2() { | 2409 | fn infer_trait_method_generic_2() { |
2320 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 2410 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
2321 | assert_snapshot_matches!( | 2411 | assert_snapshot!( |
2322 | infer(r#" | 2412 | infer(r#" |
2323 | trait Trait<T> { | 2413 | trait Trait<T> { |
2324 | fn method(&self) -> T; | 2414 | fn method(&self) -> T; |
@@ -2330,18 +2420,20 @@ fn test() { | |||
2330 | } | 2420 | } |
2331 | "#), | 2421 | "#), |
2332 | @r###" | 2422 | @r###" |
2333 | [33; 37) 'self': &Self | 2423 | |
2334 | [102; 127) '{ ...d(); }': () | 2424 | [33; 37) 'self': &Self |
2335 | [108; 109) 'S': S<u32>(T) -> S<T> | 2425 | [102; 127) '{ ...d(); }': () |
2336 | [108; 115) 'S(1u32)': S<u32> | 2426 | [108; 109) 'S': S<u32>(T) -> S<T> |
2337 | [108; 124) 'S(1u32...thod()': u32 | 2427 | [108; 115) 'S(1u32)': S<u32> |
2338 | [110; 114) '1u32': u32"### | 2428 | [108; 124) 'S(1u32...thod()': u32 |
2429 | [110; 114) '1u32': u32 | ||
2430 | "### | ||
2339 | ); | 2431 | ); |
2340 | } | 2432 | } |
2341 | 2433 | ||
2342 | #[test] | 2434 | #[test] |
2343 | fn infer_trait_assoc_method() { | 2435 | fn infer_trait_assoc_method() { |
2344 | assert_snapshot_matches!( | 2436 | assert_snapshot!( |
2345 | infer(r#" | 2437 | infer(r#" |
2346 | trait Default { | 2438 | trait Default { |
2347 | fn default() -> Self; | 2439 | fn default() -> Self; |
@@ -2355,22 +2447,24 @@ fn test() { | |||
2355 | } | 2447 | } |
2356 | "#), | 2448 | "#), |
2357 | @r###" | 2449 | @r###" |
2358 | [87; 193) '{ ...t(); }': () | 2450 | |
2359 | [97; 99) 's1': S | 2451 | [87; 193) '{ ...t(); }': () |
2360 | [105; 121) 'Defaul...efault': {unknown} | 2452 | [97; 99) 's1': S |
2361 | [105; 123) 'Defaul...ault()': S | 2453 | [105; 121) 'Defaul...efault': {unknown} |
2362 | [133; 135) 's2': {unknown} | 2454 | [105; 123) 'Defaul...ault()': S |
2363 | [138; 148) 'S::default': {unknown} | 2455 | [133; 135) 's2': {unknown} |
2364 | [138; 150) 'S::default()': {unknown} | 2456 | [138; 148) 'S::default': {unknown} |
2365 | [160; 162) 's3': {unknown} | 2457 | [138; 150) 'S::default()': {unknown} |
2366 | [165; 188) '<S as ...efault': {unknown} | 2458 | [160; 162) 's3': {unknown} |
2367 | [165; 190) '<S as ...ault()': {unknown}"### | 2459 | [165; 188) '<S as ...efault': {unknown} |
2460 | [165; 190) '<S as ...ault()': {unknown} | ||
2461 | "### | ||
2368 | ); | 2462 | ); |
2369 | } | 2463 | } |
2370 | 2464 | ||
2371 | #[test] | 2465 | #[test] |
2372 | fn infer_from_bound_1() { | 2466 | fn infer_from_bound_1() { |
2373 | assert_snapshot_matches!( | 2467 | assert_snapshot!( |
2374 | infer(r#" | 2468 | infer(r#" |
2375 | trait Trait<T> {} | 2469 | trait Trait<T> {} |
2376 | struct S<T>(T); | 2470 | struct S<T>(T); |
@@ -2382,24 +2476,23 @@ fn test() { | |||
2382 | } | 2476 | } |
2383 | "#), | 2477 | "#), |
2384 | @r###" | 2478 | @r###" |
2385 | ⋮ | 2479 | [86; 87) 't': T |
2386 | ⋮[86; 87) 't': T | 2480 | [92; 94) '{}': () |
2387 | ⋮[92; 94) '{}': () | 2481 | [105; 144) '{ ...(s); }': () |
2388 | ⋮[105; 144) '{ ...(s); }': () | 2482 | [115; 116) 's': S<u32> |
2389 | ⋮[115; 116) 's': S<u32> | 2483 | [119; 120) 'S': S<u32>(T) -> S<T> |
2390 | ⋮[119; 120) 'S': S<u32>(T) -> S<T> | 2484 | [119; 129) 'S(unknown)': S<u32> |
2391 | ⋮[119; 129) 'S(unknown)': S<u32> | 2485 | [121; 128) 'unknown': u32 |
2392 | ⋮[121; 128) 'unknown': u32 | 2486 | [135; 138) 'foo': fn foo<S<u32>>(T) -> () |
2393 | ⋮[135; 138) 'foo': fn foo<S<u32>>(T) -> () | 2487 | [135; 141) 'foo(s)': () |
2394 | ⋮[135; 141) 'foo(s)': () | 2488 | [139; 140) 's': S<u32> |
2395 | ⋮[139; 140) 's': S<u32> | ||
2396 | "### | 2489 | "### |
2397 | ); | 2490 | ); |
2398 | } | 2491 | } |
2399 | 2492 | ||
2400 | #[test] | 2493 | #[test] |
2401 | fn infer_from_bound_2() { | 2494 | fn infer_from_bound_2() { |
2402 | assert_snapshot_matches!( | 2495 | assert_snapshot!( |
2403 | infer(r#" | 2496 | infer(r#" |
2404 | trait Trait<T> {} | 2497 | trait Trait<T> {} |
2405 | struct S<T>(T); | 2498 | struct S<T>(T); |
@@ -2411,25 +2504,24 @@ fn test() { | |||
2411 | } | 2504 | } |
2412 | "#), | 2505 | "#), |
2413 | @r###" | 2506 | @r###" |
2414 | ⋮ | 2507 | [87; 88) 't': T |
2415 | ⋮[87; 88) 't': T | 2508 | [98; 100) '{}': () |
2416 | ⋮[98; 100) '{}': () | 2509 | [111; 163) '{ ...(s); }': () |
2417 | ⋮[111; 163) '{ ...(s); }': () | 2510 | [121; 122) 's': S<u32> |
2418 | ⋮[121; 122) 's': S<u32> | 2511 | [125; 126) 'S': S<u32>(T) -> S<T> |
2419 | ⋮[125; 126) 'S': S<u32>(T) -> S<T> | 2512 | [125; 135) 'S(unknown)': S<u32> |
2420 | ⋮[125; 135) 'S(unknown)': S<u32> | 2513 | [127; 134) 'unknown': u32 |
2421 | ⋮[127; 134) 'unknown': u32 | 2514 | [145; 146) 'x': u32 |
2422 | ⋮[145; 146) 'x': u32 | 2515 | [154; 157) 'foo': fn foo<u32, S<u32>>(T) -> U |
2423 | ⋮[154; 157) 'foo': fn foo<u32, S<u32>>(T) -> U | 2516 | [154; 160) 'foo(s)': u32 |
2424 | ⋮[154; 160) 'foo(s)': u32 | 2517 | [158; 159) 's': S<u32> |
2425 | ⋮[158; 159) 's': S<u32> | ||
2426 | "### | 2518 | "### |
2427 | ); | 2519 | ); |
2428 | } | 2520 | } |
2429 | 2521 | ||
2430 | #[test] | 2522 | #[test] |
2431 | fn infer_call_trait_method_on_generic_param_1() { | 2523 | fn infer_call_trait_method_on_generic_param_1() { |
2432 | assert_snapshot_matches!( | 2524 | assert_snapshot!( |
2433 | infer(r#" | 2525 | infer(r#" |
2434 | trait Trait { | 2526 | trait Trait { |
2435 | fn method() -> u32; | 2527 | fn method() -> u32; |
@@ -2439,16 +2531,18 @@ fn test<T: Trait>(t: T) { | |||
2439 | } | 2531 | } |
2440 | "#), | 2532 | "#), |
2441 | @r###" | 2533 | @r###" |
2442 | [59; 60) 't': T | 2534 | |
2443 | [65; 84) '{ ...d(); }': () | 2535 | [59; 60) 't': T |
2444 | [71; 72) 't': T | 2536 | [65; 84) '{ ...d(); }': () |
2445 | [71; 81) 't.method()': {unknown}"### | 2537 | [71; 72) 't': T |
2538 | [71; 81) 't.method()': {unknown} | ||
2539 | "### | ||
2446 | ); | 2540 | ); |
2447 | } | 2541 | } |
2448 | 2542 | ||
2449 | #[test] | 2543 | #[test] |
2450 | fn infer_call_trait_method_on_generic_param_2() { | 2544 | fn infer_call_trait_method_on_generic_param_2() { |
2451 | assert_snapshot_matches!( | 2545 | assert_snapshot!( |
2452 | infer(r#" | 2546 | infer(r#" |
2453 | trait Trait<T> { | 2547 | trait Trait<T> { |
2454 | fn method() -> T; | 2548 | fn method() -> T; |
@@ -2458,16 +2552,18 @@ fn test<U, T: Trait<U>>(t: T) { | |||
2458 | } | 2552 | } |
2459 | "#), | 2553 | "#), |
2460 | @r###" | 2554 | @r###" |
2461 | [66; 67) 't': T | 2555 | |
2462 | [72; 91) '{ ...d(); }': () | 2556 | [66; 67) 't': T |
2463 | [78; 79) 't': T | 2557 | [72; 91) '{ ...d(); }': () |
2464 | [78; 88) 't.method()': {unknown}"### | 2558 | [78; 79) 't': T |
2559 | [78; 88) 't.method()': {unknown} | ||
2560 | "### | ||
2465 | ); | 2561 | ); |
2466 | } | 2562 | } |
2467 | 2563 | ||
2468 | #[test] | 2564 | #[test] |
2469 | fn infer_with_multiple_trait_impls() { | 2565 | fn infer_with_multiple_trait_impls() { |
2470 | assert_snapshot_matches!( | 2566 | assert_snapshot!( |
2471 | infer(r#" | 2567 | infer(r#" |
2472 | trait Into<T> { | 2568 | trait Into<T> { |
2473 | fn into(self) -> T; | 2569 | fn into(self) -> T; |
@@ -2482,26 +2578,25 @@ fn test() { | |||
2482 | } | 2578 | } |
2483 | "#), | 2579 | "#), |
2484 | @r###" | 2580 | @r###" |
2485 | ⋮ | 2581 | [29; 33) 'self': Self |
2486 | ⋮[29; 33) 'self': Self | 2582 | [111; 202) '{ ...(S); }': () |
2487 | ⋮[111; 202) '{ ...(S); }': () | 2583 | [121; 122) 'x': u32 |
2488 | ⋮[121; 122) 'x': u32 | 2584 | [130; 131) 'S': S |
2489 | ⋮[130; 131) 'S': S | 2585 | [130; 138) 'S.into()': u32 |
2490 | ⋮[130; 138) 'S.into()': u32 | 2586 | [148; 149) 'y': u64 |
2491 | ⋮[148; 149) 'y': u64 | 2587 | [157; 158) 'S': S |
2492 | ⋮[157; 158) 'S': S | 2588 | [157; 165) 'S.into()': u64 |
2493 | ⋮[157; 165) 'S.into()': u64 | 2589 | [175; 176) 'z': {unknown} |
2494 | ⋮[175; 176) 'z': {unknown} | 2590 | [179; 196) 'Into::...::into': {unknown} |
2495 | ⋮[179; 196) 'Into::...::into': {unknown} | 2591 | [179; 199) 'Into::...nto(S)': {unknown} |
2496 | ⋮[179; 199) 'Into::...nto(S)': {unknown} | 2592 | [197; 198) 'S': S |
2497 | ⋮[197; 198) 'S': S | ||
2498 | "### | 2593 | "### |
2499 | ); | 2594 | ); |
2500 | } | 2595 | } |
2501 | 2596 | ||
2502 | #[test] | 2597 | #[test] |
2503 | fn infer_project_associated_type() { | 2598 | fn infer_project_associated_type() { |
2504 | assert_snapshot_matches!( | 2599 | assert_snapshot!( |
2505 | infer(r#" | 2600 | infer(r#" |
2506 | trait Iterable { | 2601 | trait Iterable { |
2507 | type Item; | 2602 | type Item; |
@@ -2515,21 +2610,20 @@ fn test<T: Iterable>() { | |||
2515 | } | 2610 | } |
2516 | "#), | 2611 | "#), |
2517 | @r###" | 2612 | @r###" |
2518 | ⋮ | 2613 | [108; 227) '{ ...ter; }': () |
2519 | ⋮[108; 227) '{ ...ter; }': () | 2614 | [118; 119) 'x': u32 |
2520 | ⋮[118; 119) 'x': u32 | 2615 | [145; 146) '1': u32 |
2521 | ⋮[145; 146) '1': u32 | 2616 | [156; 157) 'y': {unknown} |
2522 | ⋮[156; 157) 'y': {unknown} | 2617 | [183; 192) 'no_matter': {unknown} |
2523 | ⋮[183; 192) 'no_matter': {unknown} | 2618 | [202; 203) 'z': {unknown} |
2524 | ⋮[202; 203) 'z': {unknown} | 2619 | [215; 224) 'no_matter': {unknown} |
2525 | ⋮[215; 224) 'no_matter': {unknown} | ||
2526 | "### | 2620 | "### |
2527 | ); | 2621 | ); |
2528 | } | 2622 | } |
2529 | 2623 | ||
2530 | #[test] | 2624 | #[test] |
2531 | fn infer_return_associated_type() { | 2625 | fn infer_return_associated_type() { |
2532 | assert_snapshot_matches!( | 2626 | assert_snapshot!( |
2533 | infer(r#" | 2627 | infer(r#" |
2534 | trait Iterable { | 2628 | trait Iterable { |
2535 | type Item; | 2629 | type Item; |
@@ -2544,27 +2638,26 @@ fn test() { | |||
2544 | } | 2638 | } |
2545 | "#), | 2639 | "#), |
2546 | @r###" | 2640 | @r###" |
2547 | ⋮ | 2641 | [106; 107) 't': T |
2548 | ⋮[106; 107) 't': T | 2642 | [123; 125) '{}': () |
2549 | ⋮[123; 125) '{}': () | 2643 | [147; 148) 't': T |
2550 | ⋮[147; 148) 't': T | 2644 | [178; 180) '{}': () |
2551 | ⋮[178; 180) '{}': () | 2645 | [191; 236) '{ ...(S); }': () |
2552 | ⋮[191; 236) '{ ...(S); }': () | 2646 | [201; 202) 'x': {unknown} |
2553 | ⋮[201; 202) 'x': {unknown} | 2647 | [205; 209) 'foo1': fn foo1<S>(T) -> {unknown} |
2554 | ⋮[205; 209) 'foo1': fn foo1<S>(T) -> {unknown} | 2648 | [205; 212) 'foo1(S)': {unknown} |
2555 | ⋮[205; 212) 'foo1(S)': {unknown} | 2649 | [210; 211) 'S': S |
2556 | ⋮[210; 211) 'S': S | 2650 | [222; 223) 'y': u32 |
2557 | ⋮[222; 223) 'y': u32 | 2651 | [226; 230) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item |
2558 | ⋮[226; 230) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item | 2652 | [226; 233) 'foo2(S)': u32 |
2559 | ⋮[226; 233) 'foo2(S)': u32 | 2653 | [231; 232) 'S': S |
2560 | ⋮[231; 232) 'S': S | ||
2561 | "### | 2654 | "### |
2562 | ); | 2655 | ); |
2563 | } | 2656 | } |
2564 | 2657 | ||
2565 | #[test] | 2658 | #[test] |
2566 | fn infer_associated_type_bound() { | 2659 | fn infer_associated_type_bound() { |
2567 | assert_snapshot_matches!( | 2660 | assert_snapshot!( |
2568 | infer(r#" | 2661 | infer(r#" |
2569 | trait Iterable { | 2662 | trait Iterable { |
2570 | type Item; | 2663 | type Item; |
@@ -2574,33 +2667,37 @@ fn test<T: Iterable<Item=u32>>() { | |||
2574 | } | 2667 | } |
2575 | "#), | 2668 | "#), |
2576 | @r###" | 2669 | @r###" |
2577 | [67; 100) '{ ...own; }': () | 2670 | |
2578 | [77; 78) 'y': {unknown} | 2671 | [67; 100) '{ ...own; }': () |
2579 | [90; 97) 'unknown': {unknown}"### | 2672 | [77; 78) 'y': {unknown} |
2673 | [90; 97) 'unknown': {unknown} | ||
2674 | "### | ||
2580 | ); | 2675 | ); |
2581 | } | 2676 | } |
2582 | 2677 | ||
2583 | #[test] | 2678 | #[test] |
2584 | fn infer_const_body() { | 2679 | fn infer_const_body() { |
2585 | assert_snapshot_matches!( | 2680 | assert_snapshot!( |
2586 | infer(r#" | 2681 | infer(r#" |
2587 | const A: u32 = 1 + 1; | 2682 | const A: u32 = 1 + 1; |
2588 | static B: u64 = { let x = 1; x }; | 2683 | static B: u64 = { let x = 1; x }; |
2589 | "#), | 2684 | "#), |
2590 | @r###" | 2685 | @r###" |
2591 | [16; 17) '1': u32 | 2686 | |
2592 | [16; 21) '1 + 1': u32 | 2687 | [16; 17) '1': u32 |
2593 | [20; 21) '1': u32 | 2688 | [16; 21) '1 + 1': u32 |
2594 | [39; 55) '{ let ...1; x }': u64 | 2689 | [20; 21) '1': u32 |
2595 | [45; 46) 'x': u64 | 2690 | [39; 55) '{ let ...1; x }': u64 |
2596 | [49; 50) '1': u64 | 2691 | [45; 46) 'x': u64 |
2597 | [52; 53) 'x': u64"### | 2692 | [49; 50) '1': u64 |
2693 | [52; 53) 'x': u64 | ||
2694 | "### | ||
2598 | ); | 2695 | ); |
2599 | } | 2696 | } |
2600 | 2697 | ||
2601 | #[test] | 2698 | #[test] |
2602 | fn tuple_struct_fields() { | 2699 | fn tuple_struct_fields() { |
2603 | assert_snapshot_matches!( | 2700 | assert_snapshot!( |
2604 | infer(r#" | 2701 | infer(r#" |
2605 | struct S(i32, u64); | 2702 | struct S(i32, u64); |
2606 | fn test() -> u64 { | 2703 | fn test() -> u64 { |
@@ -2610,23 +2707,25 @@ fn test() -> u64 { | |||
2610 | } | 2707 | } |
2611 | "#), | 2708 | "#), |
2612 | @r###" | 2709 | @r###" |
2613 | [38; 87) '{ ... a.1 }': u64 | 2710 | |
2614 | [48; 49) 'a': S | 2711 | [38; 87) '{ ... a.1 }': u64 |
2615 | [52; 53) 'S': S(i32, u64) -> S | 2712 | [48; 49) 'a': S |
2616 | [52; 59) 'S(4, 6)': S | 2713 | [52; 53) 'S': S(i32, u64) -> S |
2617 | [54; 55) '4': i32 | 2714 | [52; 59) 'S(4, 6)': S |
2618 | [57; 58) '6': u64 | 2715 | [54; 55) '4': i32 |
2619 | [69; 70) 'b': i32 | 2716 | [57; 58) '6': u64 |
2620 | [73; 74) 'a': S | 2717 | [69; 70) 'b': i32 |
2621 | [73; 76) 'a.0': i32 | 2718 | [73; 74) 'a': S |
2622 | [82; 83) 'a': S | 2719 | [73; 76) 'a.0': i32 |
2623 | [82; 85) 'a.1': u64"### | 2720 | [82; 83) 'a': S |
2721 | [82; 85) 'a.1': u64 | ||
2722 | "### | ||
2624 | ); | 2723 | ); |
2625 | } | 2724 | } |
2626 | 2725 | ||
2627 | #[test] | 2726 | #[test] |
2628 | fn tuple_struct_with_fn() { | 2727 | fn tuple_struct_with_fn() { |
2629 | assert_snapshot_matches!( | 2728 | assert_snapshot!( |
2630 | infer(r#" | 2729 | infer(r#" |
2631 | struct S(fn(u32) -> u64); | 2730 | struct S(fn(u32) -> u64); |
2632 | fn test() -> u64 { | 2731 | fn test() -> u64 { |
@@ -2636,44 +2735,48 @@ fn test() -> u64 { | |||
2636 | } | 2735 | } |
2637 | "#), | 2736 | "#), |
2638 | @r###" | 2737 | @r###" |
2639 | [44; 102) '{ ...0(2) }': u64 | 2738 | |
2640 | [54; 55) 'a': S | 2739 | [44; 102) '{ ...0(2) }': u64 |
2641 | [58; 59) 'S': S(fn(u32) -> u64) -> S | 2740 | [54; 55) 'a': S |
2642 | [58; 68) 'S(|i| 2*i)': S | 2741 | [58; 59) 'S': S(fn(u32) -> u64) -> S |
2643 | [60; 67) '|i| 2*i': fn(u32) -> u64 | 2742 | [58; 68) 'S(|i| 2*i)': S |
2644 | [61; 62) 'i': i32 | 2743 | [60; 67) '|i| 2*i': fn(u32) -> u64 |
2645 | [64; 65) '2': i32 | 2744 | [61; 62) 'i': i32 |
2646 | [64; 67) '2*i': i32 | 2745 | [64; 65) '2': i32 |
2647 | [66; 67) 'i': i32 | 2746 | [64; 67) '2*i': i32 |
2648 | [78; 79) 'b': u64 | 2747 | [66; 67) 'i': i32 |
2649 | [82; 83) 'a': S | 2748 | [78; 79) 'b': u64 |
2650 | [82; 85) 'a.0': fn(u32) -> u64 | 2749 | [82; 83) 'a': S |
2651 | [82; 88) 'a.0(4)': u64 | 2750 | [82; 85) 'a.0': fn(u32) -> u64 |
2652 | [86; 87) '4': u32 | 2751 | [82; 88) 'a.0(4)': u64 |
2653 | [94; 95) 'a': S | 2752 | [86; 87) '4': u32 |
2654 | [94; 97) 'a.0': fn(u32) -> u64 | 2753 | [94; 95) 'a': S |
2655 | [94; 100) 'a.0(2)': u64 | 2754 | [94; 97) 'a.0': fn(u32) -> u64 |
2656 | [98; 99) '2': u32"### | 2755 | [94; 100) 'a.0(2)': u64 |
2756 | [98; 99) '2': u32 | ||
2757 | "### | ||
2657 | ); | 2758 | ); |
2658 | } | 2759 | } |
2659 | 2760 | ||
2660 | #[test] | 2761 | #[test] |
2661 | fn indexing_arrays() { | 2762 | fn indexing_arrays() { |
2662 | assert_snapshot_matches!( | 2763 | assert_snapshot!( |
2663 | infer("fn main() { &mut [9][2]; }"), | 2764 | infer("fn main() { &mut [9][2]; }"), |
2664 | @r###" | 2765 | @r###" |
2665 | [10; 26) '{ &mut...[2]; }': () | 2766 | |
2666 | [12; 23) '&mut [9][2]': &mut {unknown} | 2767 | [10; 26) '{ &mut...[2]; }': () |
2667 | [17; 20) '[9]': [i32;_] | 2768 | [12; 23) '&mut [9][2]': &mut {unknown} |
2668 | [17; 23) '[9][2]': {unknown} | 2769 | [17; 20) '[9]': [i32;_] |
2669 | [18; 19) '9': i32 | 2770 | [17; 23) '[9][2]': {unknown} |
2670 | [21; 22) '2': i32"### | 2771 | [18; 19) '9': i32 |
2772 | [21; 22) '2': i32 | ||
2773 | "### | ||
2671 | ) | 2774 | ) |
2672 | } | 2775 | } |
2673 | 2776 | ||
2674 | #[test] | 2777 | #[test] |
2675 | fn infer_macros_expanded() { | 2778 | fn infer_macros_expanded() { |
2676 | assert_snapshot_matches!( | 2779 | assert_snapshot!( |
2677 | infer(r#" | 2780 | infer(r#" |
2678 | struct Foo(Vec<i32>); | 2781 | struct Foo(Vec<i32>); |
2679 | 2782 | ||
@@ -2690,9 +2793,8 @@ fn main() { | |||
2690 | } | 2793 | } |
2691 | "#), | 2794 | "#), |
2692 | @r###" | 2795 | @r###" |
2693 | ⋮ | 2796 | [156; 182) '{ ...,2); }': () |
2694 | ⋮[156; 182) '{ ...,2); }': () | 2797 | [166; 167) 'x': Foo |
2695 | ⋮[166; 167) 'x': Foo | ||
2696 | "### | 2798 | "### |
2697 | ); | 2799 | ); |
2698 | } | 2800 | } |
@@ -3277,7 +3379,7 @@ fn test<T: ApplyL>(t: T) { | |||
3277 | 3379 | ||
3278 | #[test] | 3380 | #[test] |
3279 | fn impl_trait() { | 3381 | fn impl_trait() { |
3280 | assert_snapshot_matches!( | 3382 | assert_snapshot!( |
3281 | infer(r#" | 3383 | infer(r#" |
3282 | trait Trait<T> { | 3384 | trait Trait<T> { |
3283 | fn foo(&self) -> T; | 3385 | fn foo(&self) -> T; |
@@ -3298,37 +3400,36 @@ fn test(x: impl Trait<u64>, y: &impl Trait<u64>) { | |||
3298 | } | 3400 | } |
3299 | "#), | 3401 | "#), |
3300 | @r###" | 3402 | @r###" |
3301 | ⋮ | 3403 | [30; 34) 'self': &Self |
3302 | ⋮[30; 34) 'self': &Self | 3404 | [55; 59) 'self': &Self |
3303 | ⋮[55; 59) 'self': &Self | 3405 | [99; 101) '{}': () |
3304 | ⋮[99; 101) '{}': () | 3406 | [111; 112) 'x': impl Trait<u64> |
3305 | ⋮[111; 112) 'x': impl Trait<u64> | 3407 | [131; 132) 'y': &impl Trait<u64> |
3306 | ⋮[131; 132) 'y': &impl Trait<u64> | 3408 | [152; 269) '{ ...2(); }': () |
3307 | ⋮[152; 269) '{ ...2(); }': () | 3409 | [158; 159) 'x': impl Trait<u64> |
3308 | ⋮[158; 159) 'x': impl Trait<u64> | 3410 | [165; 166) 'y': &impl Trait<u64> |
3309 | ⋮[165; 166) 'y': &impl Trait<u64> | 3411 | [176; 177) 'z': impl Trait<u64> |
3310 | ⋮[176; 177) 'z': impl Trait<u64> | 3412 | [180; 183) 'bar': fn bar() -> impl Trait<u64> |
3311 | ⋮[180; 183) 'bar': fn bar() -> impl Trait<u64> | 3413 | [180; 185) 'bar()': impl Trait<u64> |
3312 | ⋮[180; 185) 'bar()': impl Trait<u64> | 3414 | [191; 192) 'x': impl Trait<u64> |
3313 | ⋮[191; 192) 'x': impl Trait<u64> | 3415 | [191; 198) 'x.foo()': {unknown} |
3314 | ⋮[191; 198) 'x.foo()': {unknown} | 3416 | [204; 205) 'y': &impl Trait<u64> |
3315 | ⋮[204; 205) 'y': &impl Trait<u64> | 3417 | [204; 211) 'y.foo()': {unknown} |
3316 | ⋮[204; 211) 'y.foo()': {unknown} | 3418 | [217; 218) 'z': impl Trait<u64> |
3317 | ⋮[217; 218) 'z': impl Trait<u64> | 3419 | [217; 224) 'z.foo()': {unknown} |
3318 | ⋮[217; 224) 'z.foo()': {unknown} | 3420 | [230; 231) 'x': impl Trait<u64> |
3319 | ⋮[230; 231) 'x': impl Trait<u64> | 3421 | [230; 238) 'x.foo2()': i64 |
3320 | ⋮[230; 238) 'x.foo2()': i64 | 3422 | [244; 245) 'y': &impl Trait<u64> |
3321 | ⋮[244; 245) 'y': &impl Trait<u64> | 3423 | [244; 252) 'y.foo2()': i64 |
3322 | ⋮[244; 252) 'y.foo2()': i64 | 3424 | [258; 259) 'z': impl Trait<u64> |
3323 | ⋮[258; 259) 'z': impl Trait<u64> | 3425 | [258; 266) 'z.foo2()': i64 |
3324 | ⋮[258; 266) 'z.foo2()': i64 | ||
3325 | "### | 3426 | "### |
3326 | ); | 3427 | ); |
3327 | } | 3428 | } |
3328 | 3429 | ||
3329 | #[test] | 3430 | #[test] |
3330 | fn dyn_trait() { | 3431 | fn dyn_trait() { |
3331 | assert_snapshot_matches!( | 3432 | assert_snapshot!( |
3332 | infer(r#" | 3433 | infer(r#" |
3333 | trait Trait<T> { | 3434 | trait Trait<T> { |
3334 | fn foo(&self) -> T; | 3435 | fn foo(&self) -> T; |
@@ -3349,37 +3450,36 @@ fn test(x: dyn Trait<u64>, y: &dyn Trait<u64>) { | |||
3349 | } | 3450 | } |
3350 | "#), | 3451 | "#), |
3351 | @r###" | 3452 | @r###" |
3352 | ⋮ | 3453 | [30; 34) 'self': &Self |
3353 | ⋮[30; 34) 'self': &Self | 3454 | [55; 59) 'self': &Self |
3354 | ⋮[55; 59) 'self': &Self | 3455 | [98; 100) '{}': () |
3355 | ⋮[98; 100) '{}': () | 3456 | [110; 111) 'x': dyn Trait<u64> |
3356 | ⋮[110; 111) 'x': dyn Trait<u64> | 3457 | [129; 130) 'y': &dyn Trait<u64> |
3357 | ⋮[129; 130) 'y': &dyn Trait<u64> | 3458 | [149; 266) '{ ...2(); }': () |
3358 | ⋮[149; 266) '{ ...2(); }': () | 3459 | [155; 156) 'x': dyn Trait<u64> |
3359 | ⋮[155; 156) 'x': dyn Trait<u64> | 3460 | [162; 163) 'y': &dyn Trait<u64> |
3360 | ⋮[162; 163) 'y': &dyn Trait<u64> | 3461 | [173; 174) 'z': dyn Trait<u64> |
3361 | ⋮[173; 174) 'z': dyn Trait<u64> | 3462 | [177; 180) 'bar': fn bar() -> dyn Trait<u64> |
3362 | ⋮[177; 180) 'bar': fn bar() -> dyn Trait<u64> | 3463 | [177; 182) 'bar()': dyn Trait<u64> |
3363 | ⋮[177; 182) 'bar()': dyn Trait<u64> | 3464 | [188; 189) 'x': dyn Trait<u64> |
3364 | ⋮[188; 189) 'x': dyn Trait<u64> | 3465 | [188; 195) 'x.foo()': {unknown} |
3365 | ⋮[188; 195) 'x.foo()': {unknown} | 3466 | [201; 202) 'y': &dyn Trait<u64> |
3366 | ⋮[201; 202) 'y': &dyn Trait<u64> | 3467 | [201; 208) 'y.foo()': {unknown} |
3367 | ⋮[201; 208) 'y.foo()': {unknown} | 3468 | [214; 215) 'z': dyn Trait<u64> |
3368 | ⋮[214; 215) 'z': dyn Trait<u64> | 3469 | [214; 221) 'z.foo()': {unknown} |
3369 | ⋮[214; 221) 'z.foo()': {unknown} | 3470 | [227; 228) 'x': dyn Trait<u64> |
3370 | ⋮[227; 228) 'x': dyn Trait<u64> | 3471 | [227; 235) 'x.foo2()': i64 |
3371 | ⋮[227; 235) 'x.foo2()': i64 | 3472 | [241; 242) 'y': &dyn Trait<u64> |
3372 | ⋮[241; 242) 'y': &dyn Trait<u64> | 3473 | [241; 249) 'y.foo2()': i64 |
3373 | ⋮[241; 249) 'y.foo2()': i64 | 3474 | [255; 256) 'z': dyn Trait<u64> |
3374 | ⋮[255; 256) 'z': dyn Trait<u64> | 3475 | [255; 263) 'z.foo2()': i64 |
3375 | ⋮[255; 263) 'z.foo2()': i64 | ||
3376 | "### | 3476 | "### |
3377 | ); | 3477 | ); |
3378 | } | 3478 | } |
3379 | 3479 | ||
3380 | #[test] | 3480 | #[test] |
3381 | fn dyn_trait_bare() { | 3481 | fn dyn_trait_bare() { |
3382 | assert_snapshot_matches!( | 3482 | assert_snapshot!( |
3383 | infer(r#" | 3483 | infer(r#" |
3384 | trait Trait { | 3484 | trait Trait { |
3385 | fn foo(&self) -> u64; | 3485 | fn foo(&self) -> u64; |
@@ -3396,30 +3496,29 @@ fn test(x: Trait, y: &Trait) -> u64 { | |||
3396 | } | 3496 | } |
3397 | "#), | 3497 | "#), |
3398 | @r###" | 3498 | @r###" |
3399 | ⋮ | 3499 | [27; 31) 'self': &Self |
3400 | ⋮[27; 31) 'self': &Self | 3500 | [61; 63) '{}': () |
3401 | ⋮[61; 63) '{}': () | 3501 | [73; 74) 'x': {unknown} |
3402 | ⋮[73; 74) 'x': {unknown} | 3502 | [83; 84) 'y': &{unknown} |
3403 | ⋮[83; 84) 'y': &{unknown} | 3503 | [101; 176) '{ ...o(); }': () |
3404 | ⋮[101; 176) '{ ...o(); }': () | 3504 | [107; 108) 'x': {unknown} |
3405 | ⋮[107; 108) 'x': {unknown} | 3505 | [114; 115) 'y': &{unknown} |
3406 | ⋮[114; 115) 'y': &{unknown} | 3506 | [125; 126) 'z': {unknown} |
3407 | ⋮[125; 126) 'z': {unknown} | 3507 | [129; 132) 'bar': fn bar() -> {unknown} |
3408 | ⋮[129; 132) 'bar': fn bar() -> {unknown} | 3508 | [129; 134) 'bar()': {unknown} |
3409 | ⋮[129; 134) 'bar()': {unknown} | 3509 | [140; 141) 'x': {unknown} |
3410 | ⋮[140; 141) 'x': {unknown} | 3510 | [140; 147) 'x.foo()': {unknown} |
3411 | ⋮[140; 147) 'x.foo()': {unknown} | 3511 | [153; 154) 'y': &{unknown} |
3412 | ⋮[153; 154) 'y': &{unknown} | 3512 | [153; 160) 'y.foo()': {unknown} |
3413 | ⋮[153; 160) 'y.foo()': {unknown} | 3513 | [166; 167) 'z': {unknown} |
3414 | ⋮[166; 167) 'z': {unknown} | 3514 | [166; 173) 'z.foo()': {unknown} |
3415 | ⋮[166; 173) 'z.foo()': {unknown} | ||
3416 | "### | 3515 | "### |
3417 | ); | 3516 | ); |
3418 | } | 3517 | } |
3419 | 3518 | ||
3420 | #[test] | 3519 | #[test] |
3421 | fn weird_bounds() { | 3520 | fn weird_bounds() { |
3422 | assert_snapshot_matches!( | 3521 | assert_snapshot!( |
3423 | infer(r#" | 3522 | infer(r#" |
3424 | trait Trait {} | 3523 | trait Trait {} |
3425 | fn test() { | 3524 | fn test() { |
@@ -3432,20 +3531,19 @@ fn test() { | |||
3432 | } | 3531 | } |
3433 | "#), | 3532 | "#), |
3434 | @r###" | 3533 | @r###" |
3435 | ⋮ | 3534 | [26; 237) '{ ...foo; }': () |
3436 | ⋮[26; 237) '{ ...foo; }': () | 3535 | [36; 37) 'a': impl Trait + {error} |
3437 | ⋮[36; 37) 'a': impl Trait + {error} | 3536 | [64; 67) 'foo': impl Trait + {error} |
3438 | ⋮[64; 67) 'foo': impl Trait + {error} | 3537 | [77; 78) 'b': impl {error} |
3439 | ⋮[77; 78) 'b': impl {error} | 3538 | [97; 100) 'foo': impl {error} |
3440 | ⋮[97; 100) 'foo': impl {error} | 3539 | [110; 111) 'b': impl Trait |
3441 | ⋮[110; 111) 'b': impl Trait | 3540 | [128; 131) 'foo': impl Trait |
3442 | ⋮[128; 131) 'foo': impl Trait | 3541 | [141; 142) 'b': impl {error} |
3443 | ⋮[141; 142) 'b': impl {error} | 3542 | [163; 166) 'foo': impl {error} |
3444 | ⋮[163; 166) 'foo': impl {error} | 3543 | [176; 177) 'd': impl {error} |
3445 | ⋮[176; 177) 'd': impl {error} | 3544 | [193; 196) 'foo': impl {error} |
3446 | ⋮[193; 196) 'foo': impl {error} | 3545 | [206; 207) 'e': impl Trait + {error} |
3447 | ⋮[206; 207) 'e': impl Trait + {error} | 3546 | [231; 234) 'foo': impl Trait + {error} |
3448 | ⋮[231; 234) 'foo': impl Trait + {error} | ||
3449 | "### | 3547 | "### |
3450 | ); | 3548 | ); |
3451 | } | 3549 | } |
@@ -3468,7 +3566,7 @@ fn infer(content: &str) -> String { | |||
3468 | let source_file = db.parse(file_id).ok().unwrap(); | 3566 | let source_file = db.parse(file_id).ok().unwrap(); |
3469 | 3567 | ||
3470 | let mut acc = String::new(); | 3568 | let mut acc = String::new(); |
3471 | acc.push_str("\n"); | 3569 | // acc.push_str("\n"); |
3472 | 3570 | ||
3473 | let mut infer_def = |inference_result: Arc<InferenceResult>, | 3571 | let mut infer_def = |inference_result: Arc<InferenceResult>, |
3474 | body_source_map: Arc<BodySourceMap>| { | 3572 | body_source_map: Arc<BodySourceMap>| { |
@@ -3590,10 +3688,10 @@ fn no_such_field_diagnostics() { | |||
3590 | ) | 3688 | ) |
3591 | .diagnostics(); | 3689 | .diagnostics(); |
3592 | 3690 | ||
3593 | assert_snapshot_matches!(diagnostics, @r###" | 3691 | assert_snapshot!(diagnostics, @r###" |
3594 | "baz: 62": no such field | 3692 | "baz: 62": no such field |
3595 | "{\n foo: 92,\n baz: 62,\n }": fill structure fields | 3693 | "{\n foo: 92,\n baz: 62,\n }": fill structure fields |
3596 | "### | 3694 | "### |
3597 | ); | 3695 | ); |
3598 | } | 3696 | } |
3599 | 3697 | ||