aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2021-06-15 19:36:50 +0100
committerAleksey Kladov <[email protected]>2021-06-15 19:36:50 +0100
commitb737b894cb8974361881d98d7d0a6f75839ca345 (patch)
tree6c66fcbf1b77f48208319efe83f0223b785f82bf /crates
parent7ebac5e54c51c6b8f1ddf3bb905f625416cc09fa (diff)
internal: switch some tests to minicore
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/tests/method_resolution.rs55
-rw-r--r--crates/hir_ty/src/tests/simple.rs158
2 files changed, 102 insertions, 111 deletions
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs
index 79108054c..d9b5ee9cf 100644
--- a/crates/hir_ty/src/tests/method_resolution.rs
+++ b/crates/hir_ty/src/tests/method_resolution.rs
@@ -1222,11 +1222,7 @@ fn autoderef_visibility_method() {
1222 cov_mark::check!(autoderef_candidate_not_visible); 1222 cov_mark::check!(autoderef_candidate_not_visible);
1223 check_infer( 1223 check_infer(
1224 r#" 1224 r#"
1225#[lang = "deref"] 1225//- minicore: deref
1226pub trait Deref {
1227 type Target;
1228 fn deref(&self) -> &Self::Target;
1229}
1230mod a { 1226mod a {
1231 pub struct Foo(pub char); 1227 pub struct Foo(pub char);
1232 impl Foo { 1228 impl Foo {
@@ -1243,7 +1239,7 @@ mod a {
1243 self.0 1239 self.0
1244 } 1240 }
1245 } 1241 }
1246 impl super::Deref for Bar { 1242 impl core::ops::Deref for Bar {
1247 type Target = Foo; 1243 type Target = Foo;
1248 fn deref(&self) -> &Foo { 1244 fn deref(&self) -> &Foo {
1249 &Foo('z') 1245 &Foo('z')
@@ -1257,30 +1253,29 @@ mod b {
1257} 1253}
1258 "#, 1254 "#,
1259 expect![[r#" 1255 expect![[r#"
1260 67..71 'self': &Self 1256 75..79 'self': &Foo
1261 168..172 'self': &Foo 1257 89..119 '{ ... }': char
1262 182..212 '{ ... }': char 1258 103..107 'self': &Foo
1263 196..200 'self': &Foo 1259 103..109 'self.0': char
1264 196..202 'self.0': char 1260 195..226 '{ ... }': Bar
1265 288..319 '{ ... }': Bar 1261 209..213 'Self': Bar(i32) -> Bar
1266 302..306 'Self': Bar(i32) -> Bar 1262 209..216 'Self(0)': Bar
1267 302..309 'Self(0)': Bar 1263 214..215 '0': i32
1268 307..308 '0': i32 1264 245..249 'self': &Bar
1269 338..342 'self': &Bar 1265 258..288 '{ ... }': i32
1270 351..381 '{ ... }': i32 1266 272..276 'self': &Bar
1271 365..369 'self': &Bar 1267 272..278 'self.0': i32
1272 365..371 'self.0': i32 1268 376..380 'self': &Bar
1273 465..469 'self': &Bar 1269 390..423 '{ ... }': &Foo
1274 479..512 '{ ... }': &Foo 1270 404..413 '&Foo('z')': &Foo
1275 493..502 '&Foo('z')': &Foo 1271 405..408 'Foo': Foo(char) -> Foo
1276 494..497 'Foo': Foo(char) -> Foo 1272 405..413 'Foo('z')': Foo
1277 494..502 'Foo('z')': Foo 1273 409..412 ''z'': char
1278 498..501 ''z'': char 1274 453..506 '{ ... }': ()
1279 542..595 '{ ... }': () 1275 467..468 'x': char
1280 556..557 'x': char 1276 471..489 'super:...r::new': fn new() -> Bar
1281 560..578 'super:...r::new': fn new() -> Bar 1277 471..491 'super:...:new()': Bar
1282 560..580 'super:...:new()': Bar 1278 471..499 'super:...ango()': char
1283 560..588 'super:...ango()': char
1284 "#]], 1279 "#]],
1285 ) 1280 )
1286} 1281}
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