aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests/traits.rs')
-rw-r--r--crates/hir_ty/src/tests/traits.rs82
1 files changed, 8 insertions, 74 deletions
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}