aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/tests/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/tests/traits.rs')
-rw-r--r--crates/hir_ty/src/tests/traits.rs126
1 files changed, 59 insertions, 67 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index 22e0bfc49..dd1ea817f 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -2731,9 +2731,7 @@ fn test(x: &dyn Foo) {
2731fn builtin_copy() { 2731fn builtin_copy() {
2732 check_infer_with_mismatches( 2732 check_infer_with_mismatches(
2733 r#" 2733 r#"
2734#[lang = "copy"] 2734//- minicore: copy
2735trait Copy {}
2736
2737struct IsCopy; 2735struct IsCopy;
2738impl Copy for IsCopy {} 2736impl Copy for IsCopy {}
2739struct NotCopy; 2737struct NotCopy;
@@ -2748,20 +2746,20 @@ fn test() {
2748 (IsCopy, NotCopy).test(); 2746 (IsCopy, NotCopy).test();
2749}"#, 2747}"#,
2750 expect![[r#" 2748 expect![[r#"
2751 110..114 'self': &Self 2749 78..82 'self': &Self
2752 166..267 '{ ...t(); }': () 2750 134..235 '{ ...t(); }': ()
2753 172..178 'IsCopy': IsCopy 2751 140..146 'IsCopy': IsCopy
2754 172..185 'IsCopy.test()': bool 2752 140..153 'IsCopy.test()': bool
2755 191..198 'NotCopy': NotCopy 2753 159..166 'NotCopy': NotCopy
2756 191..205 'NotCopy.test()': {unknown} 2754 159..173 'NotCopy.test()': {unknown}
2757 211..227 '(IsCop...sCopy)': (IsCopy, IsCopy) 2755 179..195 '(IsCop...sCopy)': (IsCopy, IsCopy)
2758 211..234 '(IsCop...test()': bool 2756 179..202 '(IsCop...test()': bool
2759 212..218 'IsCopy': IsCopy 2757 180..186 'IsCopy': IsCopy
2760 220..226 'IsCopy': IsCopy 2758 188..194 'IsCopy': IsCopy
2761 240..257 '(IsCop...tCopy)': (IsCopy, NotCopy) 2759 208..225 '(IsCop...tCopy)': (IsCopy, NotCopy)
2762 240..264 '(IsCop...test()': {unknown} 2760 208..232 '(IsCop...test()': {unknown}
2763 241..247 'IsCopy': IsCopy 2761 209..215 'IsCopy': IsCopy
2764 249..256 'NotCopy': NotCopy 2762 217..224 'NotCopy': NotCopy
2765 "#]], 2763 "#]],
2766 ); 2764 );
2767} 2765}
@@ -2770,9 +2768,7 @@ fn test() {
2770fn builtin_fn_def_copy() { 2768fn builtin_fn_def_copy() {
2771 check_infer_with_mismatches( 2769 check_infer_with_mismatches(
2772 r#" 2770 r#"
2773#[lang = "copy"] 2771//- minicore: copy
2774trait Copy {}
2775
2776fn foo() {} 2772fn foo() {}
2777fn bar<T: Copy>(T) -> T {} 2773fn bar<T: Copy>(T) -> T {}
2778struct Struct(usize); 2774struct Struct(usize);
@@ -2788,20 +2784,20 @@ fn test() {
2788 Enum::Variant.test(); 2784 Enum::Variant.test();
2789}"#, 2785}"#,
2790 expect![[r#" 2786 expect![[r#"
2791 41..43 '{}': () 2787 9..11 '{}': ()
2792 60..61 'T': {unknown} 2788 28..29 'T': {unknown}
2793 68..70 '{}': () 2789 36..38 '{}': ()
2794 68..70: expected T, got () 2790 36..38: expected T, got ()
2795 145..149 'self': &Self 2791 113..117 'self': &Self
2796 201..281 '{ ...t(); }': () 2792 169..249 '{ ...t(); }': ()
2797 207..210 'foo': fn foo() 2793 175..178 'foo': fn foo()
2798 207..217 'foo.test()': bool 2794 175..185 'foo.test()': bool
2799 223..226 'bar': fn bar<{unknown}>({unknown}) -> {unknown} 2795 191..194 'bar': fn bar<{unknown}>({unknown}) -> {unknown}
2800 223..233 'bar.test()': bool 2796 191..201 'bar.test()': bool
2801 239..245 'Struct': Struct(usize) -> Struct 2797 207..213 'Struct': Struct(usize) -> Struct
2802 239..252 'Struct.test()': bool 2798 207..220 'Struct.test()': bool
2803 258..271 'Enum::Variant': Variant(usize) -> Enum 2799 226..239 'Enum::Variant': Variant(usize) -> Enum
2804 258..278 'Enum::...test()': bool 2800 226..246 'Enum::...test()': bool
2805 "#]], 2801 "#]],
2806 ); 2802 );
2807} 2803}
@@ -2810,9 +2806,7 @@ fn test() {
2810fn builtin_fn_ptr_copy() { 2806fn builtin_fn_ptr_copy() {
2811 check_infer_with_mismatches( 2807 check_infer_with_mismatches(
2812 r#" 2808 r#"
2813#[lang = "copy"] 2809//- minicore: copy
2814trait Copy {}
2815
2816trait Test { fn test(&self) -> bool; } 2810trait Test { fn test(&self) -> bool; }
2817impl<T: Copy> Test for T {} 2811impl<T: Copy> Test for T {}
2818 2812
@@ -2822,17 +2816,17 @@ fn test(f1: fn(), f2: fn(usize) -> u8, f3: fn(u8, u8) -> &u8) {
2822 f3.test(); 2816 f3.test();
2823}"#, 2817}"#,
2824 expect![[r#" 2818 expect![[r#"
2825 54..58 'self': &Self 2819 22..26 'self': &Self
2826 108..110 'f1': fn() 2820 76..78 'f1': fn()
2827 118..120 'f2': fn(usize) -> u8 2821 86..88 'f2': fn(usize) -> u8
2828 139..141 'f3': fn(u8, u8) -> &u8 2822 107..109 'f3': fn(u8, u8) -> &u8
2829 162..210 '{ ...t(); }': () 2823 130..178 '{ ...t(); }': ()
2830 168..170 'f1': fn() 2824 136..138 'f1': fn()
2831 168..177 'f1.test()': bool 2825 136..145 'f1.test()': bool
2832 183..185 'f2': fn(usize) -> u8 2826 151..153 'f2': fn(usize) -> u8
2833 183..192 'f2.test()': bool 2827 151..160 'f2.test()': bool
2834 198..200 'f3': fn(u8, u8) -> &u8 2828 166..168 'f3': fn(u8, u8) -> &u8
2835 198..207 'f3.test()': bool 2829 166..175 'f3.test()': bool
2836 "#]], 2830 "#]],
2837 ); 2831 );
2838} 2832}
@@ -2841,9 +2835,7 @@ fn test(f1: fn(), f2: fn(usize) -> u8, f3: fn(u8, u8) -> &u8) {
2841fn builtin_sized() { 2835fn builtin_sized() {
2842 check_infer_with_mismatches( 2836 check_infer_with_mismatches(
2843 r#" 2837 r#"
2844#[lang = "sized"] 2838//- minicore: sized
2845trait Sized {}
2846
2847trait Test { fn test(&self) -> bool; } 2839trait Test { fn test(&self) -> bool; }
2848impl<T: Sized> Test for T {} 2840impl<T: Sized> Test for T {}
2849 2841
@@ -2854,22 +2846,22 @@ fn test() {
2854 (1u8, *"foo").test(); // not Sized 2846 (1u8, *"foo").test(); // not Sized
2855}"#, 2847}"#,
2856 expect![[r#" 2848 expect![[r#"
2857 56..60 'self': &Self 2849 22..26 'self': &Self
2858 113..228 '{ ...ized }': () 2850 79..194 '{ ...ized }': ()
2859 119..122 '1u8': u8 2851 85..88 '1u8': u8
2860 119..129 '1u8.test()': bool 2852 85..95 '1u8.test()': bool
2861 135..150 '(*"foo").test()': {unknown} 2853 101..116 '(*"foo").test()': {unknown}
2862 136..142 '*"foo"': str 2854 102..108 '*"foo"': str
2863 137..142 '"foo"': &str 2855 103..108 '"foo"': &str
2864 169..179 '(1u8, 1u8)': (u8, u8) 2856 135..145 '(1u8, 1u8)': (u8, u8)
2865 169..186 '(1u8, ...test()': bool 2857 135..152 '(1u8, ...test()': bool
2866 170..173 '1u8': u8 2858 136..139 '1u8': u8
2867 175..178 '1u8': u8 2859 141..144 '1u8': u8
2868 192..205 '(1u8, *"foo")': (u8, str) 2860 158..171 '(1u8, *"foo")': (u8, str)
2869 192..212 '(1u8, ...test()': {unknown} 2861 158..178 '(1u8, ...test()': {unknown}
2870 193..196 '1u8': u8 2862 159..162 '1u8': u8
2871 198..204 '*"foo"': str 2863 164..170 '*"foo"': str
2872 199..204 '"foo"': &str 2864 165..170 '"foo"': &str
2873 "#]], 2865 "#]],
2874 ); 2866 );
2875} 2867}