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.rs11
1 files changed, 5 insertions, 6 deletions
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs
index 86a7cd4c2..c82bda70f 100644
--- a/crates/hir_ty/src/infer/coerce.rs
+++ b/crates/hir_ty/src/infer/coerce.rs
@@ -65,7 +65,7 @@ impl<'a> InferenceContext<'a> {
65 } 65 }
66 } 66 }
67 67
68 fn coerce_inner(&mut self, mut from_ty: Ty, to_ty: &Ty) -> InferResult { 68 fn coerce_inner(&mut self, from_ty: Ty, to_ty: &Ty) -> InferResult {
69 if from_ty.is_never() { 69 if from_ty.is_never() {
70 // Subtle: If we are coercing from `!` to `?T`, where `?T` is an unbound 70 // Subtle: If we are coercing from `!` to `?T`, where `?T` is an unbound
71 // type variable, we want `?T` to fallback to `!` if not 71 // type variable, we want `?T` to fallback to `!` if not
@@ -145,10 +145,9 @@ impl<'a> InferenceContext<'a> {
145 /// To match `A` with `B`, autoderef will be performed, 145 /// To match `A` with `B`, autoderef will be performed,
146 /// calling `deref`/`deref_mut` where necessary. 146 /// calling `deref`/`deref_mut` where necessary.
147 fn coerce_ref(&mut self, from_ty: Ty, to_ty: &Ty, to_mt: Mutability) -> InferResult { 147 fn coerce_ref(&mut self, from_ty: Ty, to_ty: &Ty, to_mt: Mutability) -> InferResult {
148 let (from_mt, from_inner) = match from_ty.kind(&Interner) { 148 match from_ty.kind(&Interner) {
149 TyKind::Ref(mt, _, ty) => { 149 TyKind::Ref(mt, _, _) => {
150 coerce_mutabilities(*mt, to_mt)?; 150 coerce_mutabilities(*mt, to_mt)?;
151 (*mt, ty.clone())
152 } 151 }
153 _ => return self.unify_inner(&from_ty, to_ty), 152 _ => return self.unify_inner(&from_ty, to_ty),
154 }; 153 };
@@ -160,7 +159,7 @@ impl<'a> InferenceContext<'a> {
160 // the structure like it is. 159 // the structure like it is.
161 160
162 let canonicalized = self.canonicalize(from_ty.clone()); 161 let canonicalized = self.canonicalize(from_ty.clone());
163 let mut autoderef = autoderef::autoderef( 162 let autoderef = autoderef::autoderef(
164 self.db, 163 self.db,
165 self.resolver.krate(), 164 self.resolver.krate(),
166 InEnvironment { 165 InEnvironment {
@@ -237,7 +236,7 @@ impl<'a> InferenceContext<'a> {
237 /// or a function pointer. 236 /// or a function pointer.
238 fn coerce_from_fn_item(&mut self, from_ty: Ty, to_ty: &Ty) -> InferResult { 237 fn coerce_from_fn_item(&mut self, from_ty: Ty, to_ty: &Ty) -> InferResult {
239 match to_ty.kind(&Interner) { 238 match to_ty.kind(&Interner) {
240 TyKind::Function(b_sig) => { 239 TyKind::Function(_) => {
241 let from_sig = from_ty.callable_sig(self.db).expect("FnDef had no sig"); 240 let from_sig = from_ty.callable_sig(self.db).expect("FnDef had no sig");
242 241
243 // FIXME check ABI: Intrinsics are not coercible to function pointers 242 // FIXME check ABI: Intrinsics are not coercible to function pointers