From 4ca1981c9149fe602b548d1d3629c0cc312d30f7 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 2 May 2021 16:20:37 +0200 Subject: Fix warnings & format --- crates/hir_ty/src/builder.rs | 6 +++--- crates/hir_ty/src/infer/coerce.rs | 11 +++++------ crates/hir_ty/src/infer/unify.rs | 14 +++----------- 3 files changed, 11 insertions(+), 20 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs index 49d069541..893e727c2 100644 --- a/crates/hir_ty/src/builder.rs +++ b/crates/hir_ty/src/builder.rs @@ -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`. 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> { } } - 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 diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 3a4258e86..a635501b5 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -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), } } -- cgit v1.2.3