aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_ty/src/tests/traits.rs66
1 files changed, 46 insertions, 20 deletions
diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs
index 89b65fb5f..c93ff91ee 100644
--- a/crates/hir_ty/src/tests/traits.rs
+++ b/crates/hir_ty/src/tests/traits.rs
@@ -1919,10 +1919,26 @@ fn closure_1() {
1919fn closure_2() { 1919fn closure_2() {
1920 check_infer_with_mismatches( 1920 check_infer_with_mismatches(
1921 r#" 1921 r#"
1922 #[lang = "add"]
1923 pub trait Add<Rhs = Self> {
1924 type Output;
1925 fn add(self, rhs: Rhs) -> Self::Output;
1926 }
1927
1922 trait FnOnce<Args> { 1928 trait FnOnce<Args> {
1923 type Output; 1929 type Output;
1924 } 1930 }
1925 1931
1932 impl Add for u64 {
1933 type Output = Self;
1934 fn add(self, rhs: u64) -> Self::Output {0}
1935 }
1936
1937 impl Add for u128 {
1938 type Output = Self;
1939 fn add(self, rhs: u128) -> Self::Output {0}
1940 }
1941
1926 fn test<F: FnOnce(u32) -> u64>(f: F) { 1942 fn test<F: FnOnce(u32) -> u64>(f: F) {
1927 f(1); 1943 f(1);
1928 let g = |v| v + 1; 1944 let g = |v| v + 1;
@@ -1931,26 +1947,36 @@ fn closure_2() {
1931 } 1947 }
1932 "#, 1948 "#,
1933 expect![[r#" 1949 expect![[r#"
1934 72..73 'f': F 1950 72..76 'self': Self
1935 78..154 '{ ...+ v; }': () 1951 78..81 'rhs': Rhs
1936 84..85 'f': F 1952 203..207 'self': u64
1937 84..88 'f(1)': {unknown} 1953 209..212 'rhs': u64
1938 86..87 '1': i32 1954 235..238 '{0}': u64
1939 98..99 'g': |u64| -> {unknown} 1955 236..237 '0': u64
1940 102..111 '|v| v + 1': |u64| -> {unknown} 1956 297..301 'self': u128
1941 103..104 'v': u64 1957 303..306 'rhs': u128
1942 106..107 'v': u64 1958 330..333 '{0}': u128
1943 106..111 'v + 1': {unknown} 1959 331..332 '0': u128
1944 110..111 '1': i32 1960 368..369 'f': F
1945 117..118 'g': |u64| -> {unknown} 1961 374..450 '{ ...+ v; }': ()
1946 117..124 'g(1u64)': {unknown} 1962 380..381 'f': F
1947 119..123 '1u64': u64 1963 380..384 'f(1)': {unknown}
1948 134..135 'h': |u128| -> u128 1964 382..383 '1': i32
1949 138..151 '|v| 1u128 + v': |u128| -> u128 1965 394..395 'g': |u64| -> u64
1950 139..140 'v': u128 1966 398..407 '|v| v + 1': |u64| -> u64
1951 142..147 '1u128': u128 1967 399..400 'v': u64
1952 142..151 '1u128 + v': u128 1968 402..403 'v': u64
1953 150..151 'v': u128 1969 402..407 'v + 1': u64
1970 406..407 '1': u64
1971 413..414 'g': |u64| -> u64
1972 413..420 'g(1u64)': u64
1973 415..419 '1u64': u64
1974 430..431 'h': |u128| -> u128
1975 434..447 '|v| 1u128 + v': |u128| -> u128
1976 435..436 'v': u128
1977 438..443 '1u128': u128
1978 438..447 '1u128 + v': u128
1979 446..447 'v': u128
1954 "#]], 1980 "#]],
1955 ); 1981 );
1956} 1982}