diff options
Diffstat (limited to 'crates/hir_ty/src/tests/method_resolution.rs')
-rw-r--r-- | crates/hir_ty/src/tests/method_resolution.rs | 363 |
1 files changed, 157 insertions, 206 deletions
diff --git a/crates/hir_ty/src/tests/method_resolution.rs b/crates/hir_ty/src/tests/method_resolution.rs index f26b2c8a7..3f7a37295 100644 --- a/crates/hir_ty/src/tests/method_resolution.rs +++ b/crates/hir_ty/src/tests/method_resolution.rs | |||
@@ -257,7 +257,7 @@ fn test() { | |||
257 | mod foo { | 257 | mod foo { |
258 | struct S; | 258 | struct S; |
259 | impl S { | 259 | impl S { |
260 | fn thing() -> i128 {} | 260 | fn thing() -> i128 { 0 } |
261 | } | 261 | } |
262 | } | 262 | } |
263 | "#, | 263 | "#, |
@@ -267,164 +267,128 @@ mod foo { | |||
267 | #[test] | 267 | #[test] |
268 | fn infer_trait_method_simple() { | 268 | fn infer_trait_method_simple() { |
269 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 269 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
270 | check_infer( | 270 | check_types( |
271 | r#" | 271 | r#" |
272 | trait Trait1 { | 272 | trait Trait1 { |
273 | fn method(&self) -> u32; | 273 | fn method(&self) -> u32; |
274 | } | 274 | } |
275 | struct S1; | 275 | struct S1; |
276 | impl Trait1 for S1 {} | 276 | impl Trait1 for S1 {} |
277 | trait Trait2 { | 277 | trait Trait2 { |
278 | fn method(&self) -> i128; | 278 | fn method(&self) -> i128; |
279 | } | 279 | } |
280 | struct S2; | 280 | struct S2; |
281 | impl Trait2 for S2 {} | 281 | impl Trait2 for S2 {} |
282 | fn test() { | 282 | fn test() { |
283 | S1.method(); // -> u32 | 283 | S1.method(); |
284 | S2.method(); // -> i128 | 284 | //^^^^^^^^^^^ u32 |
285 | } | 285 | S2.method(); // -> i128 |
286 | //^^^^^^^^^^^ i128 | ||
287 | } | ||
286 | "#, | 288 | "#, |
287 | expect![[r#" | ||
288 | 30..34 'self': &Self | ||
289 | 109..113 'self': &Self | ||
290 | 169..227 '{ ...i128 }': () | ||
291 | 175..177 'S1': S1 | ||
292 | 175..186 'S1.method()': u32 | ||
293 | 202..204 'S2': S2 | ||
294 | 202..213 'S2.method()': i128 | ||
295 | "#]], | ||
296 | ); | 289 | ); |
297 | } | 290 | } |
298 | 291 | ||
299 | #[test] | 292 | #[test] |
300 | fn infer_trait_method_scoped() { | 293 | fn infer_trait_method_scoped() { |
301 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 294 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
302 | check_infer( | 295 | check_types( |
303 | r#" | 296 | r#" |
304 | struct S; | 297 | struct S; |
305 | mod foo { | 298 | mod foo { |
306 | pub trait Trait1 { | 299 | pub trait Trait1 { |
307 | fn method(&self) -> u32; | 300 | fn method(&self) -> u32; |
308 | } | 301 | } |
309 | impl Trait1 for super::S {} | 302 | impl Trait1 for super::S {} |
310 | } | 303 | } |
311 | mod bar { | 304 | mod bar { |
312 | pub trait Trait2 { | 305 | pub trait Trait2 { |
313 | fn method(&self) -> i128; | 306 | fn method(&self) -> i128; |
314 | } | 307 | } |
315 | impl Trait2 for super::S {} | 308 | impl Trait2 for super::S {} |
316 | } | 309 | } |
317 | 310 | ||
318 | mod foo_test { | 311 | mod foo_test { |
319 | use super::S; | 312 | use super::S; |
320 | use super::foo::Trait1; | 313 | use super::foo::Trait1; |
321 | fn test() { | 314 | fn test() { |
322 | S.method(); // -> u32 | 315 | S.method(); |
323 | } | 316 | //^^^^^^^^^^ u32 |
324 | } | 317 | } |
318 | } | ||
325 | 319 | ||
326 | mod bar_test { | 320 | mod bar_test { |
327 | use super::S; | 321 | use super::S; |
328 | use super::bar::Trait2; | 322 | use super::bar::Trait2; |
329 | fn test() { | 323 | fn test() { |
330 | S.method(); // -> i128 | 324 | S.method(); |
331 | } | 325 | //^^^^^^^^^^ i128 |
332 | } | 326 | } |
327 | } | ||
333 | "#, | 328 | "#, |
334 | expect![[r#" | ||
335 | 62..66 'self': &Self | ||
336 | 168..172 'self': &Self | ||
337 | 299..336 '{ ... }': () | ||
338 | 309..310 'S': S | ||
339 | 309..319 'S.method()': u32 | ||
340 | 415..453 '{ ... }': () | ||
341 | 425..426 'S': S | ||
342 | 425..435 'S.method()': i128 | ||
343 | "#]], | ||
344 | ); | 329 | ); |
345 | } | 330 | } |
346 | 331 | ||
347 | #[test] | 332 | #[test] |
348 | fn infer_trait_method_generic_1() { | 333 | fn infer_trait_method_generic_1() { |
349 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 334 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
350 | check_infer( | 335 | check_types( |
351 | r#" | 336 | r#" |
352 | trait Trait<T> { | 337 | trait Trait<T> { |
353 | fn method(&self) -> T; | 338 | fn method(&self) -> T; |
354 | } | 339 | } |
355 | struct S; | 340 | struct S; |
356 | impl Trait<u32> for S {} | 341 | impl Trait<u32> for S {} |
357 | fn test() { | 342 | fn test() { |
358 | S.method(); | 343 | S.method(); |
359 | } | 344 | //^^^^^^^^^^ u32 |
345 | } | ||
360 | "#, | 346 | "#, |
361 | expect![[r#" | ||
362 | 32..36 'self': &Self | ||
363 | 91..110 '{ ...d(); }': () | ||
364 | 97..98 'S': S | ||
365 | 97..107 'S.method()': u32 | ||
366 | "#]], | ||
367 | ); | 347 | ); |
368 | } | 348 | } |
369 | 349 | ||
370 | #[test] | 350 | #[test] |
371 | fn infer_trait_method_generic_more_params() { | 351 | fn infer_trait_method_generic_more_params() { |
372 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 352 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
373 | check_infer( | 353 | check_types( |
374 | r#" | 354 | r#" |
375 | trait Trait<T1, T2, T3> { | 355 | trait Trait<T1, T2, T3> { |
376 | fn method1(&self) -> (T1, T2, T3); | 356 | fn method1(&self) -> (T1, T2, T3); |
377 | fn method2(&self) -> (T3, T2, T1); | 357 | fn method2(&self) -> (T3, T2, T1); |
378 | } | 358 | } |
379 | struct S1; | 359 | struct S1; |
380 | impl Trait<u8, u16, u32> for S1 {} | 360 | impl Trait<u8, u16, u32> for S1 {} |
381 | struct S2; | 361 | struct S2; |
382 | impl<T> Trait<i8, i16, T> for S2 {} | 362 | impl<T> Trait<i8, i16, T> for S2 {} |
383 | fn test() { | 363 | fn test() { |
384 | S1.method1(); // u8, u16, u32 | 364 | S1.method1(); |
385 | S1.method2(); // u32, u16, u8 | 365 | //^^^^^^^^^^^^ (u8, u16, u32) |
386 | S2.method1(); // i8, i16, {unknown} | 366 | S1.method2(); |
387 | S2.method2(); // {unknown}, i16, i8 | 367 | //^^^^^^^^^^^^ (u32, u16, u8) |
388 | } | 368 | S2.method1(); |
369 | //^^^^^^^^^^^^ (i8, i16, {unknown}) | ||
370 | S2.method2(); | ||
371 | //^^^^^^^^^^^^ ({unknown}, i16, i8) | ||
372 | } | ||
389 | "#, | 373 | "#, |
390 | expect![[r#" | ||
391 | 42..46 'self': &Self | ||
392 | 81..85 'self': &Self | ||
393 | 209..360 '{ ..., i8 }': () | ||
394 | 215..217 'S1': S1 | ||
395 | 215..227 'S1.method1()': (u8, u16, u32) | ||
396 | 249..251 'S1': S1 | ||
397 | 249..261 'S1.method2()': (u32, u16, u8) | ||
398 | 283..285 'S2': S2 | ||
399 | 283..295 'S2.method1()': (i8, i16, {unknown}) | ||
400 | 323..325 'S2': S2 | ||
401 | 323..335 'S2.method2()': ({unknown}, i16, i8) | ||
402 | "#]], | ||
403 | ); | 374 | ); |
404 | } | 375 | } |
405 | 376 | ||
406 | #[test] | 377 | #[test] |
407 | fn infer_trait_method_generic_2() { | 378 | fn infer_trait_method_generic_2() { |
408 | // the trait implementation is intentionally incomplete -- it shouldn't matter | 379 | // the trait implementation is intentionally incomplete -- it shouldn't matter |
409 | check_infer( | 380 | check_types( |
410 | r#" | 381 | r#" |
411 | trait Trait<T> { | 382 | trait Trait<T> { |
412 | fn method(&self) -> T; | 383 | fn method(&self) -> T; |
413 | } | 384 | } |
414 | struct S<T>(T); | 385 | struct S<T>(T); |
415 | impl<U> Trait<U> for S<U> {} | 386 | impl<U> Trait<U> for S<U> {} |
416 | fn test() { | 387 | fn test() { |
417 | S(1u32).method(); | 388 | S(1u32).method(); |
418 | } | 389 | //^^^^^^^^^^^^^^^^ u32 |
390 | } | ||
419 | "#, | 391 | "#, |
420 | expect![[r#" | ||
421 | 32..36 'self': &Self | ||
422 | 101..126 '{ ...d(); }': () | ||
423 | 107..108 'S': S<u32>(u32) -> S<u32> | ||
424 | 107..114 'S(1u32)': S<u32> | ||
425 | 107..123 'S(1u32...thod()': u32 | ||
426 | 109..113 '1u32': u32 | ||
427 | "#]], | ||
428 | ); | 392 | ); |
429 | } | 393 | } |
430 | 394 | ||
@@ -685,10 +649,10 @@ fn method_resolution_unify_impl_self_type() { | |||
685 | check_types( | 649 | check_types( |
686 | r#" | 650 | r#" |
687 | struct S<T>; | 651 | struct S<T>; |
688 | impl S<u32> { fn foo(&self) -> u8 {} } | 652 | impl S<u32> { fn foo(&self) -> u8 { 0 } } |
689 | impl S<i32> { fn foo(&self) -> i8 {} } | 653 | impl S<i32> { fn foo(&self) -> i8 { 0 } } |
690 | fn test() { (S::<u32>.foo(), S::<i32>.foo()); } | 654 | fn test() { (S::<u32>.foo(), S::<i32>.foo()); } |
691 | //^ (u8, i8) | 655 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (u8, i8) |
692 | "#, | 656 | "#, |
693 | ); | 657 | ); |
694 | } | 658 | } |
@@ -702,7 +666,7 @@ struct S; | |||
702 | impl S { fn foo(&self) -> i8 { 0 } } | 666 | impl S { fn foo(&self) -> i8 { 0 } } |
703 | impl Trait for S { fn foo(self) -> u128 { 0 } } | 667 | impl Trait for S { fn foo(self) -> u128 { 0 } } |
704 | fn test() { S.foo(); } | 668 | fn test() { S.foo(); } |
705 | //^ u128 | 669 | //^^^^^^^ u128 |
706 | "#, | 670 | "#, |
707 | ); | 671 | ); |
708 | } | 672 | } |
@@ -716,7 +680,7 @@ struct S; | |||
716 | impl Clone for S {} | 680 | impl Clone for S {} |
717 | impl Clone for &S {} | 681 | impl Clone for &S {} |
718 | fn test() { (S.clone(), (&S).clone(), (&&S).clone()); } | 682 | fn test() { (S.clone(), (&S).clone(), (&&S).clone()); } |
719 | //^ (S, S, &S) | 683 | //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ (S, S, &S) |
720 | "#, | 684 | "#, |
721 | ); | 685 | ); |
722 | } | 686 | } |
@@ -730,7 +694,7 @@ struct S; | |||
730 | impl S { fn foo(self) -> i8 { 0 } } | 694 | impl S { fn foo(self) -> i8 { 0 } } |
731 | impl Trait for &S { fn foo(self) -> u128 { 0 } } | 695 | impl Trait for &S { fn foo(self) -> u128 { 0 } } |
732 | fn test() { (&S).foo(); } | 696 | fn test() { (&S).foo(); } |
733 | //^ u128 | 697 | //^^^^^^^^^^ u128 |
734 | "#, | 698 | "#, |
735 | ); | 699 | ); |
736 | } | 700 | } |
@@ -744,7 +708,7 @@ struct S; | |||
744 | impl S { fn foo(self) -> i8 { 0 } } | 708 | impl S { fn foo(self) -> i8 { 0 } } |
745 | impl Trait for S { fn foo(self) -> u128 { 0 } } | 709 | impl Trait for S { fn foo(self) -> u128 { 0 } } |
746 | fn test() { S.foo(); } | 710 | fn test() { S.foo(); } |
747 | //^ i8 | 711 | //^^^^^^^ i8 |
748 | "#, | 712 | "#, |
749 | ); | 713 | ); |
750 | } | 714 | } |
@@ -758,7 +722,7 @@ struct S; | |||
758 | impl S { fn foo(&self) -> i8 { 0 } } | 722 | impl S { fn foo(&self) -> i8 { 0 } } |
759 | impl Trait for &S { fn foo(self) -> u128 { 0 } } | 723 | impl Trait for &S { fn foo(self) -> u128 { 0 } } |
760 | fn test() { S.foo(); } | 724 | fn test() { S.foo(); } |
761 | //^ i8 | 725 | //^^^^^^^ i8 |
762 | "#, | 726 | "#, |
763 | ); | 727 | ); |
764 | } | 728 | } |
@@ -771,7 +735,7 @@ trait Trait { fn foo(self) -> u128; } | |||
771 | struct S; | 735 | struct S; |
772 | impl Trait for S { fn foo(self) -> u128 { 0 } } | 736 | impl Trait for S { fn foo(self) -> u128 { 0 } } |
773 | fn test() { (&S).foo(); } | 737 | fn test() { (&S).foo(); } |
774 | //^ u128 | 738 | //^^^^^^^^^^ u128 |
775 | "#, | 739 | "#, |
776 | ); | 740 | ); |
777 | } | 741 | } |
@@ -780,14 +744,11 @@ fn test() { (&S).foo(); } | |||
780 | fn method_resolution_unsize_array() { | 744 | fn method_resolution_unsize_array() { |
781 | check_types( | 745 | check_types( |
782 | r#" | 746 | r#" |
783 | #[lang = "slice"] | 747 | //- minicore: slice |
784 | impl<T> [T] { | ||
785 | fn len(&self) -> usize { loop {} } | ||
786 | } | ||
787 | fn test() { | 748 | fn test() { |
788 | let a = [1, 2, 3]; | 749 | let a = [1, 2, 3]; |
789 | a.len(); | 750 | a.len(); |
790 | } //^ usize | 751 | } //^^^^^^^ usize |
791 | "#, | 752 | "#, |
792 | ); | 753 | ); |
793 | } | 754 | } |
@@ -802,7 +763,7 @@ impl Clone for S {} | |||
802 | 763 | ||
803 | fn test() { | 764 | fn test() { |
804 | S.clone(); | 765 | S.clone(); |
805 | //^ S | 766 | //^^^^^^^^^ S |
806 | } | 767 | } |
807 | 768 | ||
808 | //- /lib.rs crate:core | 769 | //- /lib.rs crate:core |
@@ -826,7 +787,7 @@ trait Trait { fn foo(self) -> u128; } | |||
826 | struct S; | 787 | struct S; |
827 | impl<T> Trait for T where T: UnknownTrait {} | 788 | impl<T> Trait for T where T: UnknownTrait {} |
828 | fn test() { (&S).foo(); } | 789 | fn test() { (&S).foo(); } |
829 | //^ u128 | 790 | //^^^^^^^^^^ u128 |
830 | "#, | 791 | "#, |
831 | ); | 792 | ); |
832 | } | 793 | } |
@@ -844,7 +805,7 @@ trait Trait { fn foo(self) -> u128; } | |||
844 | struct S; | 805 | struct S; |
845 | impl<T> Trait for T where T: Clone {} | 806 | impl<T> Trait for T where T: Clone {} |
846 | fn test() { (&S).foo(); } | 807 | fn test() { (&S).foo(); } |
847 | //^ {unknown} | 808 | //^^^^^^^^^^ {unknown} |
848 | "#, | 809 | "#, |
849 | ); | 810 | ); |
850 | } | 811 | } |
@@ -859,7 +820,7 @@ trait Trait { fn foo(self) -> u128; } | |||
859 | struct S; | 820 | struct S; |
860 | impl<T: Clone> Trait for T {} | 821 | impl<T: Clone> Trait for T {} |
861 | fn test() { (&S).foo(); } | 822 | fn test() { (&S).foo(); } |
862 | //^ {unknown} | 823 | //^^^^^^^^^^ {unknown} |
863 | "#, | 824 | "#, |
864 | ); | 825 | ); |
865 | } | 826 | } |
@@ -874,7 +835,7 @@ struct S; | |||
874 | impl Clone for S {} | 835 | impl Clone for S {} |
875 | impl<T> Trait for T where T: Clone {} | 836 | impl<T> Trait for T where T: Clone {} |
876 | fn test() { S.foo(); } | 837 | fn test() { S.foo(); } |
877 | //^ u128 | 838 | //^^^^^^^ u128 |
878 | "#, | 839 | "#, |
879 | ); | 840 | ); |
880 | } | 841 | } |
@@ -890,7 +851,7 @@ struct S2; | |||
890 | impl From<S2> for S1 {} | 851 | impl From<S2> for S1 {} |
891 | impl<T, U> Into<U> for T where U: From<T> {} | 852 | impl<T, U> Into<U> for T where U: From<T> {} |
892 | fn test() { S2.into(); } | 853 | fn test() { S2.into(); } |
893 | //^ {unknown} | 854 | //^^^^^^^^^ {unknown} |
894 | "#, | 855 | "#, |
895 | ); | 856 | ); |
896 | } | 857 | } |
@@ -906,7 +867,7 @@ struct S2; | |||
906 | impl From<S2> for S1 {} | 867 | impl From<S2> for S1 {} |
907 | impl<T, U: From<T>> Into<U> for T {} | 868 | impl<T, U: From<T>> Into<U> for T {} |
908 | fn test() { S2.into(); } | 869 | fn test() { S2.into(); } |
909 | //^ {unknown} | 870 | //^^^^^^^^^ {unknown} |
910 | "#, | 871 | "#, |
911 | ); | 872 | ); |
912 | } | 873 | } |
@@ -936,7 +897,7 @@ fn main() { | |||
936 | let a = Wrapper::<Foo<f32>>::new(1.0); | 897 | let a = Wrapper::<Foo<f32>>::new(1.0); |
937 | let b = Wrapper::<Bar<f32>>::new(1.0); | 898 | let b = Wrapper::<Bar<f32>>::new(1.0); |
938 | (a, b); | 899 | (a, b); |
939 | //^ (Wrapper<Foo<f32>>, Wrapper<Bar<f32>>) | 900 | //^^^^^^ (Wrapper<Foo<f32>>, Wrapper<Bar<f32>>) |
940 | } | 901 | } |
941 | "#, | 902 | "#, |
942 | ); | 903 | ); |
@@ -950,7 +911,7 @@ fn method_resolution_encountering_fn_type() { | |||
950 | fn foo() {} | 911 | fn foo() {} |
951 | trait FnOnce { fn call(self); } | 912 | trait FnOnce { fn call(self); } |
952 | fn test() { foo.call(); } | 913 | fn test() { foo.call(); } |
953 | //^ {unknown} | 914 | //^^^^^^^^^^ {unknown} |
954 | "#, | 915 | "#, |
955 | ); | 916 | ); |
956 | } | 917 | } |
@@ -1016,7 +977,7 @@ where | |||
1016 | Wrapper<T>: a::Foo, | 977 | Wrapper<T>: a::Foo, |
1017 | { | 978 | { |
1018 | t.foo(); | 979 | t.foo(); |
1019 | } //^ {unknown} | 980 | } //^^^^^^^ {unknown} |
1020 | "#, | 981 | "#, |
1021 | ); | 982 | ); |
1022 | } | 983 | } |
@@ -1033,7 +994,7 @@ impl A<i32> { | |||
1033 | 994 | ||
1034 | fn main() { | 995 | fn main() { |
1035 | A::from(3); | 996 | A::from(3); |
1036 | } //^ A<i32> | 997 | } //^^^^^^^^^^ A<i32> |
1037 | "#, | 998 | "#, |
1038 | ); | 999 | ); |
1039 | } | 1000 | } |
@@ -1061,7 +1022,7 @@ trait FnX {} | |||
1061 | impl<B, C> Trait for S<B, C> where C: FnX, B: SendX {} | 1022 | impl<B, C> Trait for S<B, C> where C: FnX, B: SendX {} |
1062 | 1023 | ||
1063 | fn test() { (S {}).method(); } | 1024 | fn test() { (S {}).method(); } |
1064 | //^ () | 1025 | //^^^^^^^^^^^^^^^ () |
1065 | "#, | 1026 | "#, |
1066 | ); | 1027 | ); |
1067 | } | 1028 | } |
@@ -1146,8 +1107,8 @@ impl<T> Slice<T> { | |||
1146 | 1107 | ||
1147 | fn main() { | 1108 | fn main() { |
1148 | let foo: Slice<u32>; | 1109 | let foo: Slice<u32>; |
1149 | (foo.into_vec()); // we don't actually support arbitrary self types, but we shouldn't crash at least | 1110 | foo.into_vec(); // we shouldn't crash on this at least |
1150 | } //^ {unknown} | 1111 | } //^^^^^^^^^^^^^^ {unknown} |
1151 | "#, | 1112 | "#, |
1152 | ); | 1113 | ); |
1153 | } | 1114 | } |
@@ -1168,7 +1129,7 @@ impl dyn Foo + '_ { | |||
1168 | fn main() { | 1129 | fn main() { |
1169 | let f = &42u32 as &dyn Foo; | 1130 | let f = &42u32 as &dyn Foo; |
1170 | f.dyn_foo(); | 1131 | f.dyn_foo(); |
1171 | // ^u32 | 1132 | // ^^^^^^^^^^^ u32 |
1172 | } | 1133 | } |
1173 | "#, | 1134 | "#, |
1174 | ); | 1135 | ); |
@@ -1178,11 +1139,7 @@ fn main() { | |||
1178 | fn autoderef_visibility_field() { | 1139 | fn autoderef_visibility_field() { |
1179 | check_infer( | 1140 | check_infer( |
1180 | r#" | 1141 | r#" |
1181 | #[lang = "deref"] | 1142 | //- minicore: deref |
1182 | pub trait Deref { | ||
1183 | type Target; | ||
1184 | fn deref(&self) -> &Self::Target; | ||
1185 | } | ||
1186 | mod a { | 1143 | mod a { |
1187 | pub struct Foo(pub char); | 1144 | pub struct Foo(pub char); |
1188 | pub struct Bar(i32); | 1145 | pub struct Bar(i32); |
@@ -1191,7 +1148,7 @@ mod a { | |||
1191 | Self(0) | 1148 | Self(0) |
1192 | } | 1149 | } |
1193 | } | 1150 | } |
1194 | impl super::Deref for Bar { | 1151 | impl core::ops::Deref for Bar { |
1195 | type Target = Foo; | 1152 | type Target = Foo; |
1196 | fn deref(&self) -> &Foo { | 1153 | fn deref(&self) -> &Foo { |
1197 | &Foo('z') | 1154 | &Foo('z') |
@@ -1205,22 +1162,21 @@ mod b { | |||
1205 | } | 1162 | } |
1206 | "#, | 1163 | "#, |
1207 | expect![[r#" | 1164 | expect![[r#" |
1208 | 67..71 'self': &Self | 1165 | 107..138 '{ ... }': Bar |
1209 | 200..231 '{ ... }': Bar | 1166 | 121..125 'Self': Bar(i32) -> Bar |
1210 | 214..218 'Self': Bar(i32) -> Bar | 1167 | 121..128 'Self(0)': Bar |
1211 | 214..221 'Self(0)': Bar | 1168 | 126..127 '0': i32 |
1212 | 219..220 '0': i32 | 1169 | 226..230 'self': &Bar |
1213 | 315..319 'self': &Bar | 1170 | 240..273 '{ ... }': &Foo |
1214 | 329..362 '{ ... }': &Foo | 1171 | 254..263 '&Foo('z')': &Foo |
1215 | 343..352 '&Foo('z')': &Foo | 1172 | 255..258 'Foo': Foo(char) -> Foo |
1216 | 344..347 'Foo': Foo(char) -> Foo | 1173 | 255..263 'Foo('z')': Foo |
1217 | 344..352 'Foo('z')': Foo | 1174 | 259..262 ''z'': char |
1218 | 348..351 ''z'': char | 1175 | 303..350 '{ ... }': () |
1219 | 392..439 '{ ... }': () | 1176 | 317..318 'x': char |
1220 | 406..407 'x': char | 1177 | 321..339 'super:...r::new': fn new() -> Bar |
1221 | 410..428 'super:...r::new': fn new() -> Bar | 1178 | 321..341 'super:...:new()': Bar |
1222 | 410..430 'super:...:new()': Bar | 1179 | 321..343 'super:...ew().0': char |
1223 | 410..432 'super:...ew().0': char | ||
1224 | "#]], | 1180 | "#]], |
1225 | ) | 1181 | ) |
1226 | } | 1182 | } |
@@ -1230,11 +1186,7 @@ fn autoderef_visibility_method() { | |||
1230 | cov_mark::check!(autoderef_candidate_not_visible); | 1186 | cov_mark::check!(autoderef_candidate_not_visible); |
1231 | check_infer( | 1187 | check_infer( |
1232 | r#" | 1188 | r#" |
1233 | #[lang = "deref"] | 1189 | //- minicore: deref |
1234 | pub trait Deref { | ||
1235 | type Target; | ||
1236 | fn deref(&self) -> &Self::Target; | ||
1237 | } | ||
1238 | mod a { | 1190 | mod a { |
1239 | pub struct Foo(pub char); | 1191 | pub struct Foo(pub char); |
1240 | impl Foo { | 1192 | impl Foo { |
@@ -1251,7 +1203,7 @@ mod a { | |||
1251 | self.0 | 1203 | self.0 |
1252 | } | 1204 | } |
1253 | } | 1205 | } |
1254 | impl super::Deref for Bar { | 1206 | impl core::ops::Deref for Bar { |
1255 | type Target = Foo; | 1207 | type Target = Foo; |
1256 | fn deref(&self) -> &Foo { | 1208 | fn deref(&self) -> &Foo { |
1257 | &Foo('z') | 1209 | &Foo('z') |
@@ -1265,30 +1217,29 @@ mod b { | |||
1265 | } | 1217 | } |
1266 | "#, | 1218 | "#, |
1267 | expect![[r#" | 1219 | expect![[r#" |
1268 | 67..71 'self': &Self | 1220 | 75..79 'self': &Foo |
1269 | 168..172 'self': &Foo | 1221 | 89..119 '{ ... }': char |
1270 | 182..212 '{ ... }': char | 1222 | 103..107 'self': &Foo |
1271 | 196..200 'self': &Foo | 1223 | 103..109 'self.0': char |
1272 | 196..202 'self.0': char | 1224 | 195..226 '{ ... }': Bar |
1273 | 288..319 '{ ... }': Bar | 1225 | 209..213 'Self': Bar(i32) -> Bar |
1274 | 302..306 'Self': Bar(i32) -> Bar | 1226 | 209..216 'Self(0)': Bar |
1275 | 302..309 'Self(0)': Bar | 1227 | 214..215 '0': i32 |
1276 | 307..308 '0': i32 | 1228 | 245..249 'self': &Bar |
1277 | 338..342 'self': &Bar | 1229 | 258..288 '{ ... }': i32 |
1278 | 351..381 '{ ... }': i32 | 1230 | 272..276 'self': &Bar |
1279 | 365..369 'self': &Bar | 1231 | 272..278 'self.0': i32 |
1280 | 365..371 'self.0': i32 | 1232 | 376..380 'self': &Bar |
1281 | 465..469 'self': &Bar | 1233 | 390..423 '{ ... }': &Foo |
1282 | 479..512 '{ ... }': &Foo | 1234 | 404..413 '&Foo('z')': &Foo |
1283 | 493..502 '&Foo('z')': &Foo | 1235 | 405..408 'Foo': Foo(char) -> Foo |
1284 | 494..497 'Foo': Foo(char) -> Foo | 1236 | 405..413 'Foo('z')': Foo |
1285 | 494..502 'Foo('z')': Foo | 1237 | 409..412 ''z'': char |
1286 | 498..501 ''z'': char | 1238 | 453..506 '{ ... }': () |
1287 | 542..595 '{ ... }': () | 1239 | 467..468 'x': char |
1288 | 556..557 'x': char | 1240 | 471..489 'super:...r::new': fn new() -> Bar |
1289 | 560..578 'super:...r::new': fn new() -> Bar | 1241 | 471..491 'super:...:new()': Bar |
1290 | 560..580 'super:...:new()': Bar | 1242 | 471..499 'super:...ango()': char |
1291 | 560..588 'super:...ango()': char | ||
1292 | "#]], | 1243 | "#]], |
1293 | ) | 1244 | ) |
1294 | } | 1245 | } |
@@ -1389,11 +1340,11 @@ pub trait IntoIterator { | |||
1389 | 1340 | ||
1390 | impl<T> IntoIterator for [T; 1] { | 1341 | impl<T> IntoIterator for [T; 1] { |
1391 | type Out = T; | 1342 | type Out = T; |
1392 | fn into_iter(self) -> Self::Out {} | 1343 | fn into_iter(self) -> Self::Out { loop {} } |
1393 | } | 1344 | } |
1394 | impl<'a, T> IntoIterator for &'a [T] { | 1345 | impl<'a, T> IntoIterator for &'a [T] { |
1395 | type Out = &'a T; | 1346 | type Out = &'a T; |
1396 | fn into_iter(self) -> Self::Out {} | 1347 | fn into_iter(self) -> Self::Out { loop {} } |
1397 | } | 1348 | } |
1398 | "#, | 1349 | "#, |
1399 | ); | 1350 | ); |