diff options
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 52 |
1 files changed, 46 insertions, 6 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index d5f7a4d25..9d412ff61 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -2508,15 +2508,55 @@ struct S; | |||
2508 | impl Iterable for S { type Item = u32; } | 2508 | impl Iterable for S { type Item = u32; } |
2509 | fn test<T: Iterable>() { | 2509 | fn test<T: Iterable>() { |
2510 | let x: <S as Iterable>::Item = 1; | 2510 | let x: <S as Iterable>::Item = 1; |
2511 | let y: T::Item = no_matter; | 2511 | let y: <T as Iterable>::Item = no_matter; |
2512 | let z: T::Item = no_matter; | ||
2512 | } | 2513 | } |
2513 | "#), | 2514 | "#), |
2514 | @r###" | 2515 | @r###" |
2515 | [108; 181) '{ ...ter; }': () | 2516 | ⋮ |
2516 | [118; 119) 'x': i32 | 2517 | ⋮[108; 227) '{ ...ter; }': () |
2517 | [145; 146) '1': i32 | 2518 | ⋮[118; 119) 'x': i32 |
2518 | [156; 157) 'y': {unknown} | 2519 | ⋮[145; 146) '1': i32 |
2519 | [169; 178) 'no_matter': {unknown}"### | 2520 | ⋮[156; 157) 'y': {unknown} |
2521 | ⋮[183; 192) 'no_matter': {unknown} | ||
2522 | ⋮[202; 203) 'z': {unknown} | ||
2523 | ⋮[215; 224) 'no_matter': {unknown} | ||
2524 | "### | ||
2525 | ); | ||
2526 | } | ||
2527 | |||
2528 | #[test] | ||
2529 | fn infer_return_associated_type() { | ||
2530 | assert_snapshot_matches!( | ||
2531 | infer(r#" | ||
2532 | trait Iterable { | ||
2533 | type Item; | ||
2534 | } | ||
2535 | struct S; | ||
2536 | impl Iterable for S { type Item = u32; } | ||
2537 | fn foo1<T: Iterable>(t: T) -> T::Item {} | ||
2538 | fn foo2<T: Iterable>(t: T) -> <T as Iterable>::Item {} | ||
2539 | fn test() { | ||
2540 | let x = foo1(S); | ||
2541 | let y = foo2(S); | ||
2542 | } | ||
2543 | "#), | ||
2544 | @r###" | ||
2545 | ⋮ | ||
2546 | ⋮[106; 107) 't': T | ||
2547 | ⋮[123; 125) '{}': () | ||
2548 | ⋮[147; 148) 't': T | ||
2549 | ⋮[178; 180) '{}': () | ||
2550 | ⋮[191; 236) '{ ...(S); }': () | ||
2551 | ⋮[201; 202) 'x': {unknown} | ||
2552 | ⋮[205; 209) 'foo1': fn foo1<S>(T) -> {unknown} | ||
2553 | ⋮[205; 212) 'foo1(S)': {unknown} | ||
2554 | ⋮[210; 211) 'S': S | ||
2555 | ⋮[222; 223) 'y': {unknown} | ||
2556 | ⋮[226; 230) 'foo2': fn foo2<S>(T) -> {unknown} | ||
2557 | ⋮[226; 233) 'foo2(S)': {unknown} | ||
2558 | ⋮[231; 232) 'S': S | ||
2559 | "### | ||
2520 | ); | 2560 | ); |
2521 | } | 2561 | } |
2522 | 2562 | ||