aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-09-16 20:46:51 +0100
committerFlorian Diebold <[email protected]>2019-09-17 18:47:45 +0100
commit35d1c038967b9d69f2e501e24fec8351f3948779 (patch)
tree5915dbd2a496a0e01a05754eceb2f815610670cb /crates/ra_hir/src
parentfe1dfd2b20b256b99f40f6f6421f7c7e12c23e41 (diff)
Add test for `<T>::Item`
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty/tests.rs32
1 files changed, 22 insertions, 10 deletions
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index dc4e8683d..fdcb3c37f 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -2685,6 +2685,7 @@ fn test() {
2685 2685
2686#[test] 2686#[test]
2687fn infer_project_associated_type() { 2687fn infer_project_associated_type() {
2688 // y, z, a don't yet work because of https://github.com/rust-lang/chalk/issues/234
2688 assert_snapshot!( 2689 assert_snapshot!(
2689 infer(r#" 2690 infer(r#"
2690trait Iterable { 2691trait Iterable {
@@ -2696,16 +2697,19 @@ fn test<T: Iterable>() {
2696 let x: <S as Iterable>::Item = 1; 2697 let x: <S as Iterable>::Item = 1;
2697 let y: <T as Iterable>::Item = no_matter; 2698 let y: <T as Iterable>::Item = no_matter;
2698 let z: T::Item = no_matter; 2699 let z: T::Item = no_matter;
2700 let a: <T>::Item = no_matter;
2699} 2701}
2700"#), 2702"#),
2701 @r###" 2703 @r###"
2702 [108; 227) '{ ...ter; }': () 2704 [108; 261) '{ ...ter; }': ()
2703 [118; 119) 'x': u32 2705 [118; 119) 'x': u32
2704 [145; 146) '1': u32 2706 [145; 146) '1': u32
2705 [156; 157) 'y': {unknown} 2707 [156; 157) 'y': {unknown}
2706 [183; 192) 'no_matter': {unknown} 2708 [183; 192) 'no_matter': {unknown}
2707 [202; 203) 'z': {unknown} 2709 [202; 203) 'z': {unknown}
2708 [215; 224) 'no_matter': {unknown} 2710 [215; 224) 'no_matter': {unknown}
2711 [234; 235) 'a': {unknown}
2712 [249; 258) 'no_matter': {unknown}
2709 "### 2713 "###
2710 ); 2714 );
2711} 2715}
@@ -2721,9 +2725,11 @@ struct S;
2721impl Iterable for S { type Item = u32; } 2725impl Iterable for S { type Item = u32; }
2722fn foo1<T: Iterable>(t: T) -> T::Item {} 2726fn foo1<T: Iterable>(t: T) -> T::Item {}
2723fn foo2<T: Iterable>(t: T) -> <T as Iterable>::Item {} 2727fn foo2<T: Iterable>(t: T) -> <T as Iterable>::Item {}
2728fn foo3<T: Iterable>(t: T) -> <T>::Item {}
2724fn test() { 2729fn test() {
2725 let x = foo1(S); 2730 let x = foo1(S);
2726 let y = foo2(S); 2731 let y = foo2(S);
2732 let z = foo3(S);
2727} 2733}
2728"#), 2734"#),
2729 @r###" 2735 @r###"
@@ -2731,15 +2737,21 @@ fn test() {
2731 [123; 125) '{}': () 2737 [123; 125) '{}': ()
2732 [147; 148) 't': T 2738 [147; 148) 't': T
2733 [178; 180) '{}': () 2739 [178; 180) '{}': ()
2734 [191; 236) '{ ...(S); }': () 2740 [202; 203) 't': T
2735 [201; 202) 'x': u32 2741 [221; 223) '{}': ()
2736 [205; 209) 'foo1': fn foo1<S>(T) -> <T as Iterable>::Item 2742 [234; 300) '{ ...(S); }': ()
2737 [205; 212) 'foo1(S)': u32 2743 [244; 245) 'x': u32
2738 [210; 211) 'S': S 2744 [248; 252) 'foo1': fn foo1<S>(T) -> <T as Iterable>::Item
2739 [222; 223) 'y': u32 2745 [248; 255) 'foo1(S)': u32
2740 [226; 230) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item 2746 [253; 254) 'S': S
2741 [226; 233) 'foo2(S)': u32 2747 [265; 266) 'y': u32
2742 [231; 232) 'S': S 2748 [269; 273) 'foo2': fn foo2<S>(T) -> <T as Iterable>::Item
2749 [269; 276) 'foo2(S)': u32
2750 [274; 275) 'S': S
2751 [286; 287) 'z': u32
2752 [290; 294) 'foo3': fn foo3<S>(T) -> <T as Iterable>::Item
2753 [290; 297) 'foo3(S)': u32
2754 [295; 296) 'S': S
2743 "### 2755 "###
2744 ); 2756 );
2745} 2757}