diff options
Diffstat (limited to 'crates/hir_ty/src/infer/coerce.rs')
-rw-r--r-- | crates/hir_ty/src/infer/coerce.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 00b2b585f..60186bc5f 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -26,8 +26,8 @@ impl<'a> InferenceContext<'a> { | |||
26 | return true; | 26 | return true; |
27 | } | 27 | } |
28 | match self.coerce_inner(from_ty, &to_ty) { | 28 | match self.coerce_inner(from_ty, &to_ty) { |
29 | Ok(_result) => { | 29 | Ok(result) => { |
30 | // TODO deal with goals | 30 | self.table.register_infer_ok(result); |
31 | true | 31 | true |
32 | } | 32 | } |
33 | Err(_) => { | 33 | Err(_) => { |
@@ -67,8 +67,9 @@ impl<'a> InferenceContext<'a> { | |||
67 | let target_ty = TyKind::Function(sig.to_fn_ptr()).intern(&Interner); | 67 | let target_ty = TyKind::Function(sig.to_fn_ptr()).intern(&Interner); |
68 | let result1 = self.coerce_inner(ty1.clone(), &target_ty); | 68 | let result1 = self.coerce_inner(ty1.clone(), &target_ty); |
69 | let result2 = self.coerce_inner(ty2.clone(), &target_ty); | 69 | let result2 = self.coerce_inner(ty2.clone(), &target_ty); |
70 | if let (Ok(_result1), Ok(_result2)) = (result1, result2) { | 70 | if let (Ok(result1), Ok(result2)) = (result1, result2) { |
71 | // TODO deal with the goals | 71 | self.table.register_infer_ok(result1); |
72 | self.table.register_infer_ok(result2); | ||
72 | return target_ty; | 73 | return target_ty; |
73 | } | 74 | } |
74 | } | 75 | } |
@@ -104,7 +105,7 @@ impl<'a> InferenceContext<'a> { | |||
104 | } | 105 | } |
105 | _ => {} | 106 | _ => {} |
106 | } | 107 | } |
107 | return Ok(InferOk {}); | 108 | return Ok(InferOk { goals: Vec::new() }); |
108 | } | 109 | } |
109 | 110 | ||
110 | // Consider coercing the subtype to a DST | 111 | // Consider coercing the subtype to a DST |
@@ -416,10 +417,11 @@ impl<'a> InferenceContext<'a> { | |||
416 | }, | 417 | }, |
417 | ); | 418 | ); |
418 | } | 419 | } |
420 | // FIXME: should we accept ambiguous results here? | ||
419 | _ => return Err(TypeError), | 421 | _ => return Err(TypeError), |
420 | }; | 422 | }; |
421 | 423 | ||
422 | Ok(InferOk {}) | 424 | Ok(InferOk { goals: Vec::new() }) |
423 | } | 425 | } |
424 | } | 426 | } |
425 | 427 | ||
@@ -444,11 +446,11 @@ fn safe_to_unsafe_fn_ty(fn_ty: FnPointer) -> FnPointer { | |||
444 | } | 446 | } |
445 | } | 447 | } |
446 | 448 | ||
447 | fn coerce_mutabilities(from: Mutability, to: Mutability) -> InferResult { | 449 | fn coerce_mutabilities(from: Mutability, to: Mutability) -> Result<(), TypeError> { |
448 | match (from, to) { | 450 | match (from, to) { |
449 | (Mutability::Mut, Mutability::Mut) | 451 | (Mutability::Mut, Mutability::Mut) |
450 | | (Mutability::Mut, Mutability::Not) | 452 | | (Mutability::Mut, Mutability::Not) |
451 | | (Mutability::Not, Mutability::Not) => Ok(InferOk {}), | 453 | | (Mutability::Not, Mutability::Not) => Ok(()), |
452 | (Mutability::Not, Mutability::Mut) => Err(TypeError), | 454 | (Mutability::Not, Mutability::Mut) => Err(TypeError), |
453 | } | 455 | } |
454 | } | 456 | } |