From 0aa4ac362d1a40e4aea98857d22a2cd3884aa215 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Mon, 22 Mar 2021 19:13:43 +0100 Subject: Correctly lower TraitRefs with default params --- crates/hir_ty/src/tests/traits.rs | 46 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'crates/hir_ty/src/tests') diff --git a/crates/hir_ty/src/tests/traits.rs b/crates/hir_ty/src/tests/traits.rs index 37cd04c6f..45a1958e3 100644 --- a/crates/hir_ty/src/tests/traits.rs +++ b/crates/hir_ty/src/tests/traits.rs @@ -3324,3 +3324,49 @@ fn f() { "#]], ) } + +#[test] +fn infer_default_trait_type_parameter() { + check_infer( + r#" +struct A; + +trait Op { + type Output; + + fn do_op(self, rhs: RHS) -> Self::Output; +} + +impl Op for A { + type Output = bool; + + fn do_op(self, rhs: Self) -> Self::Output { + true + } +} + +fn test() { + let x = A; + let y = A; + let r = x.do_op(y); +} + "#, + expect![[r#" + 63..67 'self': Self + 69..72 'rhs': RHS + 153..157 'self': A + 159..162 'rhs': A + 186..206 '{ ... }': bool + 196..200 'true': bool + 220..277 '{ ...(y); }': () + 230..231 'x': A + 234..235 'A': A + 245..246 'y': A + 249..250 'A': A + 260..261 'r': bool + 264..265 'x': A + 264..274 'x.do_op(y)': bool + 272..273 'y': A + "#]], + ) +} -- cgit v1.2.3