3385: Fix #3373 r=matklad a=flodiebold

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.

Co-authored-by: Florian Diebold <flodiebold@gmail.com>
This commit is contained in:
bors[bot] 2020-03-02 13:23:24 +00:00 committed by GitHub
commit 79c874803b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 45 additions and 6 deletions

View file

@ -1048,6 +1048,25 @@ where
assert_eq!(t, "{unknown}");
}
#[test]
fn method_resolution_3373() {
let t = type_at(
r#"
//- /main.rs
struct A<T>(T);
impl A<i32> {
fn from(v: i32) -> A<i32> { A(v) }
}
fn main() {
A::from(3)<|>;
}
"#,
);
assert_eq!(t, "A<i32>");
}
#[test]
fn method_resolution_slow() {
// this can get quite slow if we set the solver size limit too high