diff options
Diffstat (limited to 'crates/hir_ty/src/tests/regression.rs')
-rw-r--r-- | crates/hir_ty/src/tests/regression.rs | 162 |
1 files changed, 76 insertions, 86 deletions
diff --git a/crates/hir_ty/src/tests/regression.rs b/crates/hir_ty/src/tests/regression.rs index 1019e783b..1edec1615 100644 --- a/crates/hir_ty/src/tests/regression.rs +++ b/crates/hir_ty/src/tests/regression.rs | |||
@@ -884,41 +884,37 @@ fn issue_4966() { | |||
884 | fn issue_6628() { | 884 | fn issue_6628() { |
885 | check_infer( | 885 | check_infer( |
886 | r#" | 886 | r#" |
887 | #[lang = "fn_once"] | 887 | //- minicore: fn |
888 | pub trait FnOnce<Args> { | 888 | struct S<T>(); |
889 | type Output; | 889 | impl<T> S<T> { |
890 | } | 890 | fn f(&self, _t: T) {} |
891 | 891 | fn g<F: FnOnce(&T)>(&self, _f: F) {} | |
892 | struct S<T>(); | 892 | } |
893 | impl<T> S<T> { | 893 | fn main() { |
894 | fn f(&self, _t: T) {} | 894 | let s = S(); |
895 | fn g<F: FnOnce(&T)>(&self, _f: F) {} | 895 | s.g(|_x| {}); |
896 | } | 896 | s.f(10); |
897 | fn main() { | 897 | } |
898 | let s = S(); | 898 | "#, |
899 | s.g(|_x| {}); | ||
900 | s.f(10); | ||
901 | } | ||
902 | "#, | ||
903 | expect![[r#" | 899 | expect![[r#" |
904 | 105..109 'self': &S<T> | 900 | 40..44 'self': &S<T> |
905 | 111..113 '_t': T | 901 | 46..48 '_t': T |
906 | 118..120 '{}': () | 902 | 53..55 '{}': () |
907 | 146..150 'self': &S<T> | 903 | 81..85 'self': &S<T> |
908 | 152..154 '_f': F | 904 | 87..89 '_f': F |
909 | 159..161 '{}': () | 905 | 94..96 '{}': () |
910 | 174..225 '{ ...10); }': () | 906 | 109..160 '{ ...10); }': () |
911 | 184..185 's': S<i32> | 907 | 119..120 's': S<i32> |
912 | 188..189 'S': S<i32>() -> S<i32> | 908 | 123..124 'S': S<i32>() -> S<i32> |
913 | 188..191 'S()': S<i32> | 909 | 123..126 'S()': S<i32> |
914 | 197..198 's': S<i32> | 910 | 132..133 's': S<i32> |
915 | 197..209 's.g(|_x| {})': () | 911 | 132..144 's.g(|_x| {})': () |
916 | 201..208 '|_x| {}': |&i32| -> () | 912 | 136..143 '|_x| {}': |&i32| -> () |
917 | 202..204 '_x': &i32 | 913 | 137..139 '_x': &i32 |
918 | 206..208 '{}': () | 914 | 141..143 '{}': () |
919 | 215..216 's': S<i32> | 915 | 150..151 's': S<i32> |
920 | 215..222 's.f(10)': () | 916 | 150..157 's.f(10)': () |
921 | 219..221 '10': i32 | 917 | 154..156 '10': i32 |
922 | "#]], | 918 | "#]], |
923 | ); | 919 | ); |
924 | } | 920 | } |
@@ -927,35 +923,33 @@ fn issue_6628() { | |||
927 | fn issue_6852() { | 923 | fn issue_6852() { |
928 | check_infer( | 924 | check_infer( |
929 | r#" | 925 | r#" |
930 | #[lang = "deref"] | 926 | //- minicore: deref |
931 | pub trait Deref { | 927 | use core::ops::Deref; |
932 | type Target; | ||
933 | } | ||
934 | 928 | ||
935 | struct BufWriter {} | 929 | struct BufWriter {} |
936 | 930 | ||
937 | struct Mutex<T> {} | 931 | struct Mutex<T> {} |
938 | struct MutexGuard<'a, T> {} | 932 | struct MutexGuard<'a, T> {} |
939 | impl<T> Mutex<T> { | 933 | impl<T> Mutex<T> { |
940 | fn lock(&self) -> MutexGuard<'_, T> {} | 934 | fn lock(&self) -> MutexGuard<'_, T> {} |
941 | } | 935 | } |
942 | impl<'a, T: 'a> Deref for MutexGuard<'a, T> { | 936 | impl<'a, T: 'a> Deref for MutexGuard<'a, T> { |
943 | type Target = T; | 937 | type Target = T; |
944 | } | 938 | } |
945 | fn flush(&self) { | 939 | fn flush(&self) { |
946 | let w: &Mutex<BufWriter>; | 940 | let w: &Mutex<BufWriter>; |
947 | *(w.lock()); | 941 | *(w.lock()); |
948 | } | 942 | } |
949 | "#, | 943 | "#, |
950 | expect![[r#" | 944 | expect![[r#" |
951 | 156..160 'self': &Mutex<T> | 945 | 123..127 'self': &Mutex<T> |
952 | 183..185 '{}': () | 946 | 150..152 '{}': () |
953 | 267..271 'self': &{unknown} | 947 | 234..238 'self': &{unknown} |
954 | 273..323 '{ ...()); }': () | 948 | 240..290 '{ ...()); }': () |
955 | 283..284 'w': &Mutex<BufWriter> | 949 | 250..251 'w': &Mutex<BufWriter> |
956 | 309..320 '*(w.lock())': BufWriter | 950 | 276..287 '*(w.lock())': BufWriter |
957 | 311..312 'w': &Mutex<BufWriter> | 951 | 278..279 'w': &Mutex<BufWriter> |
958 | 311..319 'w.lock()': MutexGuard<BufWriter> | 952 | 278..286 'w.lock()': MutexGuard<BufWriter> |
959 | "#]], | 953 | "#]], |
960 | ); | 954 | ); |
961 | } | 955 | } |
@@ -977,37 +971,33 @@ fn param_overrides_fn() { | |||
977 | fn lifetime_from_chalk_during_deref() { | 971 | fn lifetime_from_chalk_during_deref() { |
978 | check_types( | 972 | check_types( |
979 | r#" | 973 | r#" |
980 | #[lang = "deref"] | 974 | //- minicore: deref |
981 | pub trait Deref { | 975 | struct Box<T: ?Sized> {} |
982 | type Target; | 976 | impl<T> core::ops::Deref for Box<T> { |
983 | } | 977 | type Target = T; |
984 | |||
985 | struct Box<T: ?Sized> {} | ||
986 | impl<T> Deref for Box<T> { | ||
987 | type Target = T; | ||
988 | 978 | ||
989 | fn deref(&self) -> &Self::Target { | 979 | fn deref(&self) -> &Self::Target { |
990 | loop {} | 980 | loop {} |
991 | } | 981 | } |
992 | } | 982 | } |
993 | 983 | ||
994 | trait Iterator { | 984 | trait Iterator { |
995 | type Item; | 985 | type Item; |
996 | } | 986 | } |
997 | 987 | ||
998 | pub struct Iter<'a, T: 'a> { | 988 | pub struct Iter<'a, T: 'a> { |
999 | inner: Box<dyn IterTrait<'a, T, Item = &'a T> + 'a>, | 989 | inner: Box<dyn IterTrait<'a, T, Item = &'a T> + 'a>, |
1000 | } | 990 | } |
1001 | 991 | ||
1002 | trait IterTrait<'a, T: 'a>: Iterator<Item = &'a T> { | 992 | trait IterTrait<'a, T: 'a>: Iterator<Item = &'a T> { |
1003 | fn clone_box(&self); | 993 | fn clone_box(&self); |
1004 | } | 994 | } |
1005 | 995 | ||
1006 | fn clone_iter<T>(s: Iter<T>) { | 996 | fn clone_iter<T>(s: Iter<T>) { |
1007 | s.inner.clone_box(); | 997 | s.inner.clone_box(); |
1008 | //^^^^^^^^^^^^^^^^^^^ () | 998 | //^^^^^^^^^^^^^^^^^^^ () |
1009 | } | 999 | } |
1010 | "#, | 1000 | "#, |
1011 | ) | 1001 | ) |
1012 | } | 1002 | } |
1013 | 1003 | ||