diff options
Diffstat (limited to 'crates/hir_ty/src/tests')
-rw-r--r-- | crates/hir_ty/src/tests/method_resolution.rs | 19 | ||||
-rw-r--r-- | crates/hir_ty/src/tests/regression.rs | 43 |
2 files changed, 62 insertions, 0 deletions
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index 0f17ff151..a6a54e542 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs | |||
@@ -1087,3 +1087,22 @@ fn method_resolution_foreign_opaque_type() { | |||
1087 | "#]], | 1087 | "#]], |
1088 | ); | 1088 | ); |
1089 | } | 1089 | } |
1090 | |||
1091 | #[test] | ||
1092 | fn method_with_allocator_box_self_type() { | ||
1093 | check_types( | ||
1094 | r#" | ||
1095 | struct Slice<T> {} | ||
1096 | struct Box<T, A> {} | ||
1097 | |||
1098 | impl<T> Slice<T> { | ||
1099 | pub fn into_vec<A>(self: Box<Self, A>) { } | ||
1100 | } | ||
1101 | |||
1102 | fn main() { | ||
1103 | let foo: Slice<u32>; | ||
1104 | (foo.into_vec()); // we don't actually support arbitrary self types, but we shouldn't crash at least | ||
1105 | } //^ {unknown} | ||
1106 | "#, | ||
1107 | ); | ||
1108 | } | ||
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 94d86b0d1..8cf4e7012 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs | |||
@@ -840,3 +840,46 @@ fn issue_4966() { | |||
840 | "#]], | 840 | "#]], |
841 | ); | 841 | ); |
842 | } | 842 | } |
843 | |||
844 | #[test] | ||
845 | fn issue_6628() { | ||
846 | check_infer( | ||
847 | r#" | ||
848 | #[lang = "fn_once"] | ||
849 | pub trait FnOnce<Args> { | ||
850 | type Output; | ||
851 | } | ||
852 | |||
853 | struct S<T>(); | ||
854 | impl<T> S<T> { | ||
855 | fn f(&self, _t: T) {} | ||
856 | fn g<F: FnOnce(&T)>(&self, _f: F) {} | ||
857 | } | ||
858 | fn main() { | ||
859 | let s = S(); | ||
860 | s.g(|_x| {}); | ||
861 | s.f(10); | ||
862 | } | ||
863 | "#, | ||
864 | expect![[r#" | ||
865 | 105..109 'self': &S<T> | ||
866 | 111..113 '_t': T | ||
867 | 118..120 '{}': () | ||
868 | 146..150 'self': &S<T> | ||
869 | 152..154 '_f': F | ||
870 | 159..161 '{}': () | ||
871 | 174..225 '{ ...10); }': () | ||
872 | 184..185 's': S<i32> | ||
873 | 188..189 'S': S<i32>() -> S<i32> | ||
874 | 188..191 'S()': S<i32> | ||
875 | 197..198 's': S<i32> | ||
876 | 197..209 's.g(|_x| {})': () | ||
877 | 201..208 '|_x| {}': |&i32| -> () | ||
878 | 202..204 '_x': &i32 | ||
879 | 206..208 '{}': () | ||
880 | 215..216 's': S<i32> | ||
881 | 215..222 's.f(10)': () | ||
882 | 219..221 '10': i32 | ||
883 | "#]], | ||
884 | ); | ||
885 | } | ||