From 2745cb37c16600c99083cefdf5eb45a5205dd86d Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 19 Jun 2020 16:29:38 +0200 Subject: Use correct substs for super trait assoc types When referring to an associated type of a super trait, we used the substs of the subtrait. That led to the #4931 crash if the subtrait had less parameters, but it could also lead to other incorrectness if just the order was different. Fixes #4931. --- crates/ra_hir_ty/src/tests/regression.rs | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'crates/ra_hir_ty/src/tests/regression.rs') diff --git a/crates/ra_hir_ty/src/tests/regression.rs b/crates/ra_hir_ty/src/tests/regression.rs index ed43df484..8dc5603b7 100644 --- a/crates/ra_hir_ty/src/tests/regression.rs +++ b/crates/ra_hir_ty/src/tests/regression.rs @@ -665,3 +665,31 @@ impl Foo { "### ); } + +#[test] +fn issue_4931() { + assert_snapshot!( + infer(r#" +trait Div { + type Output; +} + +trait CheckedDiv: Div<()> {} + +trait PrimInt: CheckedDiv { + fn pow(self); +} + +fn check(i: T) { + i.pow(); +} +"#), + @r###" + 118..122 'self': Self + 149..150 'i': T + 155..171 '{ ...w(); }': () + 161..162 'i': T + 161..168 'i.pow()': () + "### + ); +} -- cgit v1.2.3