aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/simple.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests/simple.rs')
-rw-r--r--crates/hir_ty/src/tests/simple.rs158
1 files changed, 77 insertions, 81 deletions
diff --git a/crates/hir_ty/src/tests/simple.rs b/crates/hir_ty/src/tests/simple.rs
index 3418ed21e..81d0215cf 100644
--- a/crates/hir_ty/src/tests/simple.rs
+++ b/crates/hir_ty/src/tests/simple.rs
@@ -951,62 +951,57 @@ fn infer_argument_autoderef() {
951fn infer_method_argument_autoderef() { 951fn infer_method_argument_autoderef() {
952 check_infer( 952 check_infer(
953 r#" 953 r#"
954 #[lang = "deref"] 954//- minicore: deref
955 pub trait Deref { 955use core::ops::Deref;
956 type Target; 956struct A<T>(*mut T);
957 fn deref(&self) -> &Self::Target;
958 }
959 957
960 struct A<T>(*mut T); 958impl<T> A<T> {
959 fn foo(&self, x: &A<T>) -> &T {
960 &*x.0
961 }
962}
961 963
962 impl<T> A<T> { 964struct B<T>(T);
963 fn foo(&self, x: &A<T>) -> &T {
964 &*x.0
965 }
966 }
967 965
968 struct B<T>(T); 966impl<T> Deref for B<T> {
969 967 type Target = T;
970 impl<T> Deref for B<T> { 968 fn deref(&self) -> &Self::Target {
971 type Target = T; 969 &self.0
972 fn deref(&self) -> &Self::Target { 970 }
973 &self.0 971}
974 }
975 }
976 972
977 fn test(a: A<i32>) { 973fn test(a: A<i32>) {
978 let t = A(0 as *mut _).foo(&&B(B(a))); 974 let t = A(0 as *mut _).foo(&&B(B(a)));
979 } 975}
980 "#, 976"#,
981 expect![[r#" 977 expect![[r#"
982 67..71 'self': &Self 978 71..75 'self': &A<T>
983 143..147 'self': &A<T> 979 77..78 'x': &A<T>
984 149..150 'x': &A<T> 980 93..114 '{ ... }': &T
985 165..186 '{ ... }': &T 981 103..108 '&*x.0': &T
986 175..180 '&*x.0': &T 982 104..108 '*x.0': T
987 176..180 '*x.0': T 983 105..106 'x': &A<T>
988 177..178 'x': &A<T> 984 105..108 'x.0': *mut T
989 177..180 'x.0': *mut T 985 195..199 'self': &B<T>
990 267..271 'self': &B<T> 986 218..241 '{ ... }': &T
991 290..313 '{ ... }': &T 987 228..235 '&self.0': &T
992 300..307 '&self.0': &T 988 229..233 'self': &B<T>
993 301..305 'self': &B<T> 989 229..235 'self.0': T
994 301..307 'self.0': T 990 253..254 'a': A<i32>
995 325..326 'a': A<i32> 991 264..310 '{ ...))); }': ()
996 336..382 '{ ...))); }': () 992 274..275 't': &i32
997 346..347 't': &i32 993 278..279 'A': A<i32>(*mut i32) -> A<i32>
998 350..351 'A': A<i32>(*mut i32) -> A<i32> 994 278..292 'A(0 as *mut _)': A<i32>
999 350..364 'A(0 as *mut _)': A<i32> 995 278..307 'A(0 as...B(a)))': &i32
1000 350..379 'A(0 as...B(a)))': &i32 996 280..281 '0': i32
1001 352..353 '0': i32 997 280..291 '0 as *mut _': *mut i32
1002 352..363 '0 as *mut _': *mut i32 998 297..306 '&&B(B(a))': &&B<B<A<i32>>>
1003 369..378 '&&B(B(a))': &&B<B<A<i32>>> 999 298..306 '&B(B(a))': &B<B<A<i32>>>
1004 370..378 '&B(B(a))': &B<B<A<i32>>> 1000 299..300 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>>
1005 371..372 'B': B<B<A<i32>>>(B<A<i32>>) -> B<B<A<i32>>> 1001 299..306 'B(B(a))': B<B<A<i32>>>
1006 371..378 'B(B(a))': B<B<A<i32>>> 1002 301..302 'B': B<A<i32>>(A<i32>) -> B<A<i32>>
1007 373..374 'B': B<A<i32>>(A<i32>) -> B<A<i32>> 1003 301..305 'B(a)': B<A<i32>>
1008 373..377 'B(a)': B<A<i32>> 1004 303..304 'a': A<i32>
1009 375..376 'a': A<i32>
1010 "#]], 1005 "#]],
1011 ); 1006 );
1012} 1007}
@@ -1015,15 +1010,15 @@ fn infer_method_argument_autoderef() {
1015fn infer_in_elseif() { 1010fn infer_in_elseif() {
1016 check_infer( 1011 check_infer(
1017 r#" 1012 r#"
1018 struct Foo { field: i32 } 1013struct Foo { field: i32 }
1019 fn main(foo: Foo) { 1014fn main(foo: Foo) {
1020 if true { 1015 if true {
1021 1016
1022 } else if false { 1017 } else if false {
1023 foo.field 1018 foo.field
1024 } 1019 }
1025 } 1020}
1026 "#, 1021"#,
1027 expect![[r#" 1022 expect![[r#"
1028 34..37 'foo': Foo 1023 34..37 'foo': Foo
1029 44..108 '{ ... } }': () 1024 44..108 '{ ... } }': ()
@@ -1043,28 +1038,29 @@ fn infer_in_elseif() {
1043fn infer_if_match_with_return() { 1038fn infer_if_match_with_return() {
1044 check_infer( 1039 check_infer(
1045 r#" 1040 r#"
1046 fn foo() { 1041fn foo() {
1047 let _x1 = if true { 1042 let _x1 = if true {
1048 1 1043 1
1049 } else { 1044 } else {
1050 return; 1045 return;
1051 }; 1046 };
1052 let _x2 = if true { 1047 let _x2 = if true {
1053 2 1048 2
1054 } else { 1049 } else {
1055 return 1050 return
1056 }; 1051 };
1057 let _x3 = match true { 1052 let _x3 = match true {
1058 true => 3, 1053 true => 3,
1059 _ => { 1054 _ => {
1060 return; 1055 return;
1061 } 1056 }
1062 }; 1057 };
1063 let _x4 = match true { 1058 let _x4 = match true {
1064 true => 4, 1059 true => 4,
1065 _ => return 1060 _ => return
1066 }; 1061 };
1067 }"#, 1062}
1063"#,
1068 expect![[r#" 1064 expect![[r#"
1069 9..322 '{ ... }; }': () 1065 9..322 '{ ... }; }': ()
1070 19..22 '_x1': i32 1066 19..22 '_x1': i32