From d9554c258b9c1cc2a328572e5671bc2a87729b18 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sat, 10 Apr 2021 17:16:35 +0200 Subject: Add manual ops::Add impls to test::traits::closure_2 --- crates/hir_ty/src/tests/traits.rs | 66 +++++++++++++++++++++++++++------------ 1 file changed, 46 insertions(+), 20 deletions(-) (limited to 'crates') 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() { fn closure_2() { check_infer_with_mismatches( r#" + #[lang = "add"] + pub trait Add { + type Output; + fn add(self, rhs: Rhs) -> Self::Output; + } + trait FnOnce { type Output; } + impl Add for u64 { + type Output = Self; + fn add(self, rhs: u64) -> Self::Output {0} + } + + impl Add for u128 { + type Output = Self; + fn add(self, rhs: u128) -> Self::Output {0} + } + fn test u64>(f: F) { f(1); let g = |v| v + 1; @@ -1931,26 +1947,36 @@ fn closure_2() { } "#, expect![[r#" - 72..73 'f': F - 78..154 '{ ...+ v; }': () - 84..85 'f': F - 84..88 'f(1)': {unknown} - 86..87 '1': i32 - 98..99 'g': |u64| -> {unknown} - 102..111 '|v| v + 1': |u64| -> {unknown} - 103..104 'v': u64 - 106..107 'v': u64 - 106..111 'v + 1': {unknown} - 110..111 '1': i32 - 117..118 'g': |u64| -> {unknown} - 117..124 'g(1u64)': {unknown} - 119..123 '1u64': u64 - 134..135 'h': |u128| -> u128 - 138..151 '|v| 1u128 + v': |u128| -> u128 - 139..140 'v': u128 - 142..147 '1u128': u128 - 142..151 '1u128 + v': u128 - 150..151 'v': u128 + 72..76 'self': Self + 78..81 'rhs': Rhs + 203..207 'self': u64 + 209..212 'rhs': u64 + 235..238 '{0}': u64 + 236..237 '0': u64 + 297..301 'self': u128 + 303..306 'rhs': u128 + 330..333 '{0}': u128 + 331..332 '0': u128 + 368..369 'f': F + 374..450 '{ ...+ v; }': () + 380..381 'f': F + 380..384 'f(1)': {unknown} + 382..383 '1': i32 + 394..395 'g': |u64| -> u64 + 398..407 '|v| v + 1': |u64| -> u64 + 399..400 'v': u64 + 402..403 'v': u64 + 402..407 'v + 1': u64 + 406..407 '1': u64 + 413..414 'g': |u64| -> u64 + 413..420 'g(1u64)': u64 + 415..419 '1u64': u64 + 430..431 'h': |u128| -> u128 + 434..447 '|v| 1u128 + v': |u128| -> u128 + 435..436 'v': u128 + 438..443 '1u128': u128 + 438..447 '1u128 + v': u128 + 446..447 'v': u128 "#]], ); } -- cgit v1.2.3