aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests
diff options
context:
space:
mode:
authorBenjamin Coenen <[email protected]>2020-10-28 11:29:42 +0000
committerBenjamin Coenen <[email protected]>2020-10-28 13:07:12 +0000
commitef2f7bb2438e66fd046791bb67849b6c61d946ab (patch)
tree5a00c8683a031f026bddf2fb33645b4af2c5fdaf /crates/hir_ty/src/tests
parent8762b797fd37e9a9cab3e5fe534a9672f30e6022 (diff)
do not use associated types placeholder for inlay hint
Signed-off-by: Benjamin Coenen <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r--crates/hir_ty/src/tests/method_resolution.rs40
-rw-r--r--crates/hir_ty/src/tests/regression.rs8
-rw-r--r--crates/hir_ty/src/tests/traits.rs82
3 files changed, 32 insertions, 98 deletions
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs
index 0f17ff151..596d4f182 100644
--- a/crates/hir_ty/src/tests/method_resolution.rs
+++ b/crates/hir_ty/src/tests/method_resolution.rs
@@ -108,16 +108,16 @@ fn infer_associated_method_with_modules() {
108 check_infer( 108 check_infer(
109 r#" 109 r#"
110 mod a { 110 mod a {
111 struct A; 111 pub struct A;
112 impl A { pub fn thing() -> A { A {} }} 112 impl A { pub fn thing() -> A { A {} }}
113 } 113 }
114 114
115 mod b { 115 mod b {
116 struct B; 116 pub struct B;
117 impl B { pub fn thing() -> u32 { 99 }} 117 impl B { pub fn thing() -> u32 { 99 }}
118 118
119 mod c { 119 pub mod c {
120 struct C; 120 pub struct C;
121 impl C { pub fn thing() -> C { C {} }} 121 impl C { pub fn thing() -> C { C {} }}
122 } 122 }
123 } 123 }
@@ -130,22 +130,22 @@ fn infer_associated_method_with_modules() {
130 } 130 }
131 "#, 131 "#,
132 expect![[r#" 132 expect![[r#"
133 55..63 '{ A {} }': A 133 59..67 '{ A {} }': a::A
134 57..61 'A {}': A 134 61..65 'A {}': a::A
135 125..131 '{ 99 }': u32 135 133..139 '{ 99 }': u32
136 127..129 '99': u32 136 135..137 '99': u32
137 201..209 '{ C {} }': C 137 217..225 '{ C {} }': c::C
138 203..207 'C {}': C 138 219..223 'C {}': c::C
139 240..324 '{ ...g(); }': () 139 256..340 '{ ...g(); }': ()
140 250..251 'x': A 140 266..267 'x': a::A
141 254..265 'a::A::thing': fn thing() -> A 141 270..281 'a::A::thing': fn thing() -> A
142 254..267 'a::A::thing()': A 142 270..283 'a::A::thing()': a::A
143 277..278 'y': u32 143 293..294 'y': u32
144 281..292 'b::B::thing': fn thing() -> u32 144 297..308 'b::B::thing': fn thing() -> u32
145 281..294 'b::B::thing()': u32 145 297..310 'b::B::thing()': u32
146 304..305 'z': C 146 320..321 'z': c::C
147 308..319 'c::C::thing': fn thing() -> C 147 324..335 'c::C::thing': fn thing() -> C
148 308..321 'c::C::thing()': C 148 324..337 'c::C::thing()': c::C
149 "#]], 149 "#]],
150 ); 150 );
151} 151}
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs
index 66e171f24..42d08f12c 100644
--- a/crates/hir_ty/src/tests/regression.rs
+++ b/crates/hir_ty/src/tests/regression.rs
@@ -831,11 +831,11 @@ fn issue_4966() {
831 356..362 'repeat': Repeat<Map<|&f64| -> f64>> 831 356..362 'repeat': Repeat<Map<|&f64| -> f64>>
832 365..390 'Repeat...nner }': Repeat<Map<|&f64| -> f64>> 832 365..390 'Repeat...nner }': Repeat<Map<|&f64| -> f64>>
833 383..388 'inner': Map<|&f64| -> f64> 833 383..388 'inner': Map<|&f64| -> f64>
834 401..404 'vec': Vec<<Repeat<Map<|&f64| -> f64>> as IntoIterator>::Item> 834 401..404 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
835 407..416 'from_iter': fn from_iter<<Repeat<Map<|&f64| -> f64>> as IntoIterator>::Item, Repeat<Map<|&f64| -> f64>>>(Repeat<Map<|&f64| -> f64>>) -> Vec<<Repeat<Map<|&f64| -> f64>> as IntoIterator>::Item> 835 407..416 'from_iter': fn from_iter<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>, Repeat<Map<|&f64| -> f64>>>(Repeat<Map<|&f64| -> f64>>) -> Vec<<Repeat<Map<|&f64| -> f64>> as IntoIterator>::Item>
836 407..424 'from_i...epeat)': Vec<<Repeat<Map<|&f64| -> f64>> as IntoIterator>::Item> 836 407..424 'from_i...epeat)': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
837 417..423 'repeat': Repeat<Map<|&f64| -> f64>> 837 417..423 'repeat': Repeat<Map<|&f64| -> f64>>
838 431..434 'vec': Vec<<Repeat<Map<|&f64| -> f64>> as IntoIterator>::Item> 838 431..434 'vec': Vec<IntoIterator::Item<Repeat<Map<|&f64| -> f64>>>>
839 431..444 'vec.foo_bar()': {unknown} 839 431..444 'vec.foo_bar()': {unknown}
840 "#]], 840 "#]],
841 ); 841 );
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index e98d7c064..4d193dea9 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -1,7 +1,7 @@
1use expect_test::expect; 1use expect_test::expect;
2use test_utils::mark; 2use test_utils::mark;
3 3
4use super::{check_infer, check_infer_with_mismatches, check_types, check_types_source_code}; 4use super::{check_infer, check_infer_with_mismatches, check_types};
5 5
6#[test] 6#[test]
7fn infer_await() { 7fn infer_await() {
@@ -384,12 +384,12 @@ fn infer_project_associated_type() {
384 108..261 '{ ...ter; }': () 384 108..261 '{ ...ter; }': ()
385 118..119 'x': u32 385 118..119 'x': u32
386 145..146 '1': u32 386 145..146 '1': u32
387 156..157 'y': <T as Iterable>::Item 387 156..157 'y': Iterable::Item<T>
388 183..192 'no_matter': <T as Iterable>::Item 388 183..192 'no_matter': Iterable::Item<T>
389 202..203 'z': <T as Iterable>::Item 389 202..203 'z': Iterable::Item<T>
390 215..224 'no_matter': <T as Iterable>::Item 390 215..224 'no_matter': Iterable::Item<T>
391 234..235 'a': <T as Iterable>::Item 391 234..235 'a': Iterable::Item<T>
392 249..258 'no_matter': <T as Iterable>::Item 392 249..258 'no_matter': Iterable::Item<T>
393 "#]], 393 "#]],
394 ); 394 );
395} 395}
@@ -946,45 +946,6 @@ fn test<T: ApplyL>(t: T) {
946} 946}
947 947
948#[test] 948#[test]
949fn associated_type_placeholder() {
950 check_types_source_code(
951 r#"
952pub trait ApplyL {
953 type Out;
954}
955
956pub struct RefMutL<T>;
957
958impl<T> ApplyL for RefMutL<T> {
959 type Out = <T as ApplyL>::Out;
960}
961
962fn test<T: ApplyL>() {
963 let y: <RefMutL<T> as ApplyL>::Out = no_matter;
964 y;
965} //^ ApplyL::Out<T>
966"#,
967 );
968}
969
970#[test]
971fn associated_type_placeholder_2() {
972 check_types_source_code(
973 r#"
974pub trait ApplyL {
975 type Out;
976}
977fn foo<T: ApplyL>(t: T) -> <T as ApplyL>::Out;
978
979fn test<T: ApplyL>(t: T) {
980 let y = foo(t);
981 y;
982} //^ ApplyL::Out<T>
983"#,
984 );
985}
986
987#[test]
988fn argument_impl_trait() { 949fn argument_impl_trait() {
989 check_infer_with_mismatches( 950 check_infer_with_mismatches(
990 r#" 951 r#"
@@ -2158,7 +2119,7 @@ fn unselected_projection_on_impl_self() {
2158 "#, 2119 "#,
2159 expect![[r#" 2120 expect![[r#"
2160 40..44 'self': &Self 2121 40..44 'self': &Self
2161 46..47 'x': <Self as Trait>::Item 2122 46..47 'x': Trait::Item<Self>
2162 126..130 'self': &S 2123 126..130 'self': &S
2163 132..133 'x': u32 2124 132..133 'x': u32
2164 147..161 '{ let y = x; }': () 2125 147..161 '{ let y = x; }': ()
@@ -3189,30 +3150,3 @@ fn test() {
3189 "#, 3150 "#,
3190 ); 3151 );
3191} 3152}
3192
3193#[test]
3194fn infer_call_method_return_associated_types_with_generic() {
3195 check_infer(
3196 r#"
3197 pub trait Default {
3198 fn default() -> Self;
3199 }
3200 pub trait Foo {
3201 type Bar: Default;
3202 }
3203
3204 pub fn quux<T: Foo>() -> T::Bar {
3205 let y = Default::default();
3206
3207 y
3208 }
3209 "#,
3210 expect![[r#"
3211 122..164 '{ ... y }': <T as Foo>::Bar
3212 132..133 'y': <T as Foo>::Bar
3213 136..152 'Defaul...efault': fn default<<T as Foo>::Bar>() -> <T as Foo>::Bar
3214 136..154 'Defaul...ault()': <T as Foo>::Bar
3215 161..162 'y': <T as Foo>::Bar
3216 "#]],
3217 );
3218}