diff options
author | adamrk <[email protected]> | 2020-06-20 07:13:14 +0100 |
---|---|---|
committer | adamrk <[email protected]> | 2020-06-20 07:26:31 +0100 |
commit | cf870af8073e3a72fdfb1d36b017f0abd7593559 (patch) | |
tree | deeda64f2aeafeaf0e8aed47da226f62f221a4eb /crates/ra_hir_ty/src | |
parent | 3f94a90c7bbc1b3116a7960ae9f25ebe35d68ad0 (diff) |
Switch back callable_sig for known fn types
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/infer/coerce.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/crates/ra_hir_ty/src/infer/coerce.rs b/crates/ra_hir_ty/src/infer/coerce.rs index 4c5f171de..32c7c57cd 100644 --- a/crates/ra_hir_ty/src/infer/coerce.rs +++ b/crates/ra_hir_ty/src/infer/coerce.rs | |||
@@ -38,8 +38,8 @@ impl<'a> InferenceContext<'a> { | |||
38 | // Special case: two function types. Try to coerce both to | 38 | // Special case: two function types. Try to coerce both to |
39 | // pointers to have a chance at getting a match. See | 39 | // pointers to have a chance at getting a match. See |
40 | // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 | 40 | // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 |
41 | let sig1 = self.callable_sig(ty1).expect("FnDef without callable sig"); | 41 | let sig1 = ty1.callable_sig(self.db).expect("FnDef without callable sig"); |
42 | let sig2 = self.callable_sig(ty2).expect("FnDef without callable sig"); | 42 | let sig2 = ty2.callable_sig(self.db).expect("FnDef without callable sig"); |
43 | let ptr_ty1 = Ty::fn_ptr(sig1); | 43 | let ptr_ty1 = Ty::fn_ptr(sig1); |
44 | let ptr_ty2 = Ty::fn_ptr(sig2); | 44 | let ptr_ty2 = Ty::fn_ptr(sig2); |
45 | self.coerce_merge_branch(&ptr_ty1, &ptr_ty2) | 45 | self.coerce_merge_branch(&ptr_ty1, &ptr_ty2) |
@@ -93,7 +93,7 @@ impl<'a> InferenceContext<'a> { | |||
93 | 93 | ||
94 | // `{function_type}` -> `fn()` | 94 | // `{function_type}` -> `fn()` |
95 | (ty_app!(TypeCtor::FnDef(_)), ty_app!(TypeCtor::FnPtr { .. })) => { | 95 | (ty_app!(TypeCtor::FnDef(_)), ty_app!(TypeCtor::FnPtr { .. })) => { |
96 | match self.callable_sig(&from_ty) { | 96 | match from_ty.callable_sig(self.db) { |
97 | None => return false, | 97 | None => return false, |
98 | Some(sig) => { | 98 | Some(sig) => { |
99 | from_ty = Ty::fn_ptr(sig); | 99 | from_ty = Ty::fn_ptr(sig); |
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs index bba6daeb9..a23d8abd6 100644 --- a/crates/ra_hir_ty/src/infer/expr.rs +++ b/crates/ra_hir_ty/src/infer/expr.rs | |||
@@ -768,7 +768,7 @@ impl<'a> InferenceContext<'a> { | |||
768 | let method_ty = method_ty.subst(&substs); | 768 | let method_ty = method_ty.subst(&substs); |
769 | let method_ty = self.insert_type_vars(method_ty); | 769 | let method_ty = self.insert_type_vars(method_ty); |
770 | self.register_obligations_for_call(&method_ty); | 770 | self.register_obligations_for_call(&method_ty); |
771 | let (expected_receiver_ty, param_tys, ret_ty) = match self.callable_sig(&method_ty) { | 771 | let (expected_receiver_ty, param_tys, ret_ty) = match method_ty.callable_sig(self.db) { |
772 | Some(sig) => { | 772 | Some(sig) => { |
773 | if !sig.params().is_empty() { | 773 | if !sig.params().is_empty() { |
774 | (sig.params()[0].clone(), sig.params()[1..].to_vec(), sig.ret().clone()) | 774 | (sig.params()[0].clone(), sig.params()[1..].to_vec(), sig.ret().clone()) |