Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/hir-ty/src/infer/cast.rs')
-rw-r--r--crates/hir-ty/src/infer/cast.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/hir-ty/src/infer/cast.rs b/crates/hir-ty/src/infer/cast.rs
index d3de86f038..0670a4ec3d 100644
--- a/crates/hir-ty/src/infer/cast.rs
+++ b/crates/hir-ty/src/infer/cast.rs
@@ -50,7 +50,7 @@ impl CastTy {
None
}
}
- TyKind::Raw(m, ty) => Some(Self::Ptr(table.resolve_ty_shallow(ty), *m)),
+ TyKind::Raw(m, ty) => Some(Self::Ptr(ty.clone(), *m)),
TyKind::Function(_) => Some(Self::FnPtr),
_ => None,
}
@@ -105,9 +105,8 @@ impl CastCheck {
F: FnMut(ExprId, Vec<Adjustment>),
G: FnMut(ExprId),
{
- table.resolve_obligations_as_possible();
- self.expr_ty = table.resolve_ty_shallow(&self.expr_ty);
- self.cast_ty = table.resolve_ty_shallow(&self.cast_ty);
+ self.expr_ty = table.eagerly_normalize_and_resolve_shallow_in(self.expr_ty.clone());
+ self.cast_ty = table.eagerly_normalize_and_resolve_shallow_in(self.cast_ty.clone());
if self.expr_ty.contains_unknown() || self.cast_ty.contains_unknown() {
return Ok(());
@@ -153,7 +152,7 @@ impl CastCheck {
(None, Some(t_cast)) => match self.expr_ty.kind(Interner) {
TyKind::FnDef(..) => {
let sig = self.expr_ty.callable_sig(table.db).expect("FnDef had no sig");
- let sig = table.normalize_associated_types_in(sig);
+ let sig = table.eagerly_normalize_and_resolve_shallow_in(sig);
let fn_ptr = TyKind::Function(sig.to_fn_ptr()).intern(Interner);
if let Ok((adj, _)) = table.coerce(&self.expr_ty, &fn_ptr, CoerceNever::Yes)
{
@@ -165,7 +164,6 @@ impl CastCheck {
(CastTy::FnPtr, t_cast)
}
TyKind::Ref(mutbl, _, inner_ty) => {
- let inner_ty = table.resolve_ty_shallow(inner_ty);
return match t_cast {
CastTy::Int(_) | CastTy::Float => match inner_ty.kind(Interner) {
TyKind::Scalar(
@@ -180,13 +178,13 @@ impl CastCheck {
},
// array-ptr-cast
CastTy::Ptr(t, m) => {
- let t = table.resolve_ty_shallow(&t);
+ let t = table.eagerly_normalize_and_resolve_shallow_in(t);
if !table.is_sized(&t) {
return Err(CastError::IllegalCast);
}
self.check_ref_cast(
table,
- &inner_ty,
+ inner_ty,
*mutbl,
&t,
m,
@@ -359,7 +357,7 @@ impl CastCheck {
}
}
-#[derive(PartialEq, Eq)]
+#[derive(Debug, PartialEq, Eq)]
enum PointerKind {
// thin pointer
Thin,
@@ -373,8 +371,7 @@ enum PointerKind {
}
fn pointer_kind(ty: &Ty, table: &mut InferenceTable<'_>) -> Result<Option<PointerKind>, ()> {
- let ty = table.resolve_ty_shallow(ty);
- let ty = table.normalize_associated_types_in(ty);
+ let ty = table.eagerly_normalize_and_resolve_shallow_in(ty.clone());
if table.is_sized(&ty) {
return Ok(Some(PointerKind::Thin));