Minor cleanup
This commit is contained in:
parent
64a1b26b8d
commit
f73d0ee439
@ -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.
|
||||
|
@ -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<InferOk<(Vec<Adjustment>, 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,
|
||||
|
Loading…
Reference in New Issue
Block a user