Fix warnings & format

This commit is contained in:
Florian Diebold 2021-05-02 16:20:37 +02:00
parent 693582946f
commit 4ca1981c91
3 changed files with 11 additions and 20 deletions

View file

@ -6,15 +6,15 @@ use chalk_ir::{
cast::{Cast, CastTo, Caster},
fold::Fold,
interner::HasInterner,
AdtId, BoundVar, DebruijnIndex, Safety, Scalar,
AdtId, BoundVar, DebruijnIndex, Scalar,
};
use hir_def::{builtin_type::BuiltinType, GenericDefId, TraitId, TypeAliasId};
use smallvec::SmallVec;
use crate::{
db::HirDatabase, primitive, to_assoc_type_id, to_chalk_trait_id, utils::generics, Binders,
CallableSig, FnPointer, FnSig, FnSubst, GenericArg, Interner, ProjectionTy, Substitution,
TraitRef, Ty, TyDefId, TyExt, TyKind, ValueTyDefId,
CallableSig, GenericArg, Interner, ProjectionTy, Substitution, TraitRef, Ty, TyDefId, TyExt,
TyKind, ValueTyDefId,
};
/// This is a builder for `Ty` or anything that needs a `Substitution`.

View file

@ -65,7 +65,7 @@ impl<'a> InferenceContext<'a> {
}
}
fn coerce_inner(&mut self, mut from_ty: Ty, to_ty: &Ty) -> InferResult {
fn coerce_inner(&mut self, from_ty: Ty, to_ty: &Ty) -> InferResult {
if from_ty.is_never() {
// Subtle: If we are coercing from `!` to `?T`, where `?T` is an unbound
// type variable, we want `?T` to fallback to `!` if not
@ -145,10 +145,9 @@ impl<'a> InferenceContext<'a> {
/// To match `A` with `B`, autoderef will be performed,
/// calling `deref`/`deref_mut` where necessary.
fn coerce_ref(&mut self, from_ty: Ty, to_ty: &Ty, to_mt: Mutability) -> InferResult {
let (from_mt, from_inner) = match from_ty.kind(&Interner) {
TyKind::Ref(mt, _, ty) => {
match from_ty.kind(&Interner) {
TyKind::Ref(mt, _, _) => {
coerce_mutabilities(*mt, to_mt)?;
(*mt, ty.clone())
}
_ => return self.unify_inner(&from_ty, to_ty),
};
@ -160,7 +159,7 @@ impl<'a> InferenceContext<'a> {
// the structure like it is.
let canonicalized = self.canonicalize(from_ty.clone());
let mut autoderef = autoderef::autoderef(
let autoderef = autoderef::autoderef(
self.db,
self.resolver.krate(),
InEnvironment {
@ -237,7 +236,7 @@ impl<'a> InferenceContext<'a> {
/// or a function pointer.
fn coerce_from_fn_item(&mut self, from_ty: Ty, to_ty: &Ty) -> InferResult {
match to_ty.kind(&Interner) {
TyKind::Function(b_sig) => {
TyKind::Function(_) => {
let from_sig = from_ty.callable_sig(self.db).expect("FnDef had no sig");
// FIXME check ABI: Intrinsics are not coercible to function pointers

View file

@ -134,18 +134,10 @@ pub(super) struct TypeVariableTable {
}
impl TypeVariableTable {
fn push(&mut self, data: TypeVariableData) {
self.inner.push(data);
}
pub(super) fn set_diverging(&mut self, iv: InferenceVar, diverging: bool) {
self.inner[iv.index() as usize].diverging = diverging;
}
fn is_diverging(&mut self, iv: InferenceVar) -> bool {
self.inner[iv.index() as usize].diverging
}
fn fallback_value(&self, iv: InferenceVar, kind: TyVariableKind) -> Ty {
match kind {
_ if self.inner[iv.index() as usize].diverging => TyKind::Never,
@ -221,7 +213,7 @@ impl<'a> InferenceTable<'a> {
/// Unify two types and register new trait goals that arise from that.
// TODO give these two functions better names
pub(crate) fn unify(&mut self, ty1: &Ty, ty2: &Ty) -> bool {
let result = if let Ok(r) = self.unify_inner(ty1, ty2) {
let _result = if let Ok(r) = self.unify_inner(ty1, ty2) {
r
} else {
return false;
@ -241,11 +233,11 @@ impl<'a> InferenceTable<'a> {
ty1,
ty2,
) {
Ok(result) => {
Ok(_result) => {
// TODO deal with new goals
Ok(InferOk {})
}
Err(NoSolution) => Err(TypeError),
Err(chalk_ir::NoSolution) => Err(TypeError),
}
}