diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index a66caa369ca..630d72f6e69 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -34,10 +34,10 @@ use stdx::impl_from; use syntax::SmolStr; -use super::{DomainGoal, InEnvironment, ProjectionTy, TraitEnvironment, TraitRef, Ty}; use crate::{ db::HirDatabase, fold_tys, lower::ImplTraitLoweringMode, to_assoc_type_id, AliasEq, AliasTy, - Goal, Interner, Substitution, TyBuilder, TyExt, TyKind, + DomainGoal, Goal, InEnvironment, Interner, ProjectionTy, Substitution, TraitEnvironment, + TraitRef, Ty, TyBuilder, TyExt, TyKind, }; // This lint has a false positive here. See the link below for details. diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 7a624090b65..46d1f9afe10 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -10,13 +10,14 @@ use crate::{ autoderef, - infer::{Adjust, Adjustment, AutoBorrow, InferResult, PointerCast, TypeMismatch}, - static_lifetime, Canonical, DomainGoal, FnPointer, FnSig, Interner, Solution, Substitution, Ty, - TyBuilder, TyExt, TyKind, + infer::{ + Adjust, Adjustment, AutoBorrow, InferOk, InferResult, InferenceContext, PointerCast, + TypeError, TypeMismatch, + }, + static_lifetime, Canonical, DomainGoal, FnPointer, FnSig, InEnvironment, Interner, Solution, + Substitution, Ty, TyBuilder, TyExt, TyKind, }; -use super::{InEnvironment, InferOk, InferenceContext, TypeError}; - pub(crate) type CoerceResult = Result, Ty)>, TypeError>; /// Do not require any adjustments, i.e. coerce `x -> x`. @@ -36,6 +37,7 @@ fn success( ) -> CoerceResult { Ok(InferOk { goals, value: (adj, target) }) } + #[derive(Clone, Debug)] pub(super) struct CoerceMany { expected_ty: Ty, @@ -171,12 +173,8 @@ fn coerce_inner(&mut self, from_ty: Ty, to_ty: &Ty) -> CoerceResult { // Examine the supertype and consider auto-borrowing. match to_ty.kind(&Interner) { - TyKind::Raw(mt, _) => { - return self.coerce_ptr(from_ty, to_ty, *mt); - } - TyKind::Ref(mt, _, _) => { - return self.coerce_ref(from_ty, to_ty, *mt); - } + TyKind::Raw(mt, _) => return self.coerce_ptr(from_ty, to_ty, *mt), + TyKind::Ref(mt, _, _) => return self.coerce_ref(from_ty, to_ty, *mt), _ => {} } @@ -337,7 +335,7 @@ fn coerce_ref(&mut self, from_ty: Ty, to_ty: &Ty, to_mt: Mutability) -> CoerceRe return Err(err); } }; - // FIXME: record overloarded deref adjustments + // FIXME: record overloaded deref adjustments success( vec![Adjustment { kind: Adjust::Borrow(AutoBorrow::Ref(to_mt)), target: ty.clone() }], ty,