aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/tests.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-07-14 13:19:00 +0100
committerFlorian Diebold <[email protected]>2019-08-12 20:43:00 +0100
commit3a9a0bc968d9bb97c80f18b4323b3ad75cc8bbad (patch)
treee5346bea5c8d1cdbb79b87367d08d70697da5b9e /crates/ra_hir/src/ty/tests.rs
parent0cf48e48d75d267bfa38ff1319e7f7c0468fb53f (diff)
Add another test for assoc type resolution
Diffstat (limited to 'crates/ra_hir/src/ty/tests.rs')
-rw-r--r--crates/ra_hir/src/ty/tests.rs52
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;
2508impl Iterable for S { type Item = u32; } 2508impl Iterable for S { type Item = u32; }
2509fn test<T: Iterable>() { 2509fn 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]
2529fn infer_return_associated_type() {
2530 assert_snapshot_matches!(
2531 infer(r#"
2532trait Iterable {
2533 type Item;
2534}
2535struct S;
2536impl Iterable for S { type Item = u32; }
2537fn foo1<T: Iterable>(t: T) -> T::Item {}
2538fn foo2<T: Iterable>(t: T) -> <T as Iterable>::Item {}
2539fn 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