From 336a3c6121edf54a19728dbbd880f62bc835d7c8 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 1 Mar 2020 14:31:35 +0100 Subject: Fix #3373 Basically, we need to allow variables in the caller self type to unify with the impl's declared self type. That requires some more contortions in the variable handling. I'm looking forward to (hopefully) handling this in a cleaner way when we switch to Chalk's types and unification code. --- crates/ra_hir_ty/src/tests/method_resolution.rs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'crates/ra_hir_ty/src/tests') diff --git a/crates/ra_hir_ty/src/tests/method_resolution.rs b/crates/ra_hir_ty/src/tests/method_resolution.rs index f9b394f05..af3e5b12c 100644 --- a/crates/ra_hir_ty/src/tests/method_resolution.rs +++ b/crates/ra_hir_ty/src/tests/method_resolution.rs @@ -1048,6 +1048,25 @@ where assert_eq!(t, "{unknown}"); } +#[test] +fn method_resolution_3373() { + let t = type_at( + r#" +//- /main.rs +struct A(T); + +impl A { + fn from(v: i32) -> A { A(v) } +} + +fn main() { + A::from(3)<|>; +} +"#, + ); + assert_eq!(t, "A"); +} + #[test] fn method_resolution_slow() { // this can get quite slow if we set the solver size limit too high -- cgit v1.2.3