aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer/coerce.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer/coerce.rs')
-rw-r--r--crates/hir_ty/src/infer/coerce.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs
index 911343cb9..c85c088f7 100644
--- a/crates/hir_ty/src/infer/coerce.rs
+++ b/crates/hir_ty/src/infer/coerce.rs
@@ -23,7 +23,7 @@ impl<'a> InferenceContext<'a> {
23 if to_ty.is_unknown() { 23 if to_ty.is_unknown() {
24 return true; 24 return true;
25 } 25 }
26 let from_ty = self.resolve_ty_shallow(from_ty).into_owned(); 26 let from_ty = self.resolve_ty_shallow(from_ty);
27 let to_ty = self.resolve_ty_shallow(to_ty); 27 let to_ty = self.resolve_ty_shallow(to_ty);
28 match self.coerce_inner(from_ty, &to_ty) { 28 match self.coerce_inner(from_ty, &to_ty) {
29 Ok(_result) => { 29 Ok(_result) => {
@@ -46,9 +46,7 @@ impl<'a> InferenceContext<'a> {
46 /// least upper bound. 46 /// least upper bound.
47 pub(super) fn coerce_merge_branch(&mut self, ty1: &Ty, ty2: &Ty) -> Ty { 47 pub(super) fn coerce_merge_branch(&mut self, ty1: &Ty, ty2: &Ty) -> Ty {
48 let ty1 = self.resolve_ty_shallow(ty1); 48 let ty1 = self.resolve_ty_shallow(ty1);
49 let ty1 = ty1.as_ref();
50 let ty2 = self.resolve_ty_shallow(ty2); 49 let ty2 = self.resolve_ty_shallow(ty2);
51 let ty2 = ty2.as_ref();
52 // Special case: two function types. Try to coerce both to 50 // Special case: two function types. Try to coerce both to
53 // pointers to have a chance at getting a match. See 51 // pointers to have a chance at getting a match. See
54 // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916 52 // https://github.com/rust-lang/rust/blob/7b805396bf46dce972692a6846ce2ad8481c5f85/src/librustc_typeck/check/coercion.rs#L877-L916
@@ -80,9 +78,9 @@ impl<'a> InferenceContext<'a> {
80 // type is a type variable and the new one is `!`, trying it the other 78 // type is a type variable and the new one is `!`, trying it the other
81 // way around first would mean we make the type variable `!`, instead of 79 // way around first would mean we make the type variable `!`, instead of
82 // just marking it as possibly diverging. 80 // just marking it as possibly diverging.
83 if self.coerce(ty2, ty1) { 81 if self.coerce(&ty2, &ty1) {
84 ty1.clone() 82 ty1.clone()
85 } else if self.coerce(ty1, ty2) { 83 } else if self.coerce(&ty1, &ty2) {
86 ty2.clone() 84 ty2.clone()
87 } else { 85 } else {
88 // TODO record a type mismatch 86 // TODO record a type mismatch