From d992736e796501b2a5ae232644924a3dfefede92 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 14:35:15 +0200 Subject: Remove unused --- crates/hir_ty/src/builder.rs | 2 +- crates/hir_ty/src/chalk_cast.rs | 20 ++------------------ crates/hir_ty/src/infer.rs | 1 - crates/hir_ty/src/infer/coerce.rs | 4 ++-- crates/hir_ty/src/infer/expr.rs | 1 - crates/hir_ty/src/infer/unify.rs | 2 +- crates/hir_ty/src/lib.rs | 3 --- crates/hir_ty/src/lower.rs | 2 +- crates/hir_ty/src/method_resolution.rs | 10 +++------- crates/hir_ty/src/traits.rs | 12 ++---------- crates/hir_ty/src/traits/chalk.rs | 2 +- crates/hir_ty/src/traits/chalk/mapping.rs | 7 +++---- crates/hir_ty/src/utils.rs | 14 +------------- crates/hir_ty/src/walk.rs | 9 +++------ 14 files changed, 20 insertions(+), 69 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs index 9a698898b..e25ef866d 100644 --- a/crates/hir_ty/src/builder.rs +++ b/crates/hir_ty/src/builder.rs @@ -14,7 +14,7 @@ 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, TypeWalk, ValueTyDefId, + 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/chalk_cast.rs b/crates/hir_ty/src/chalk_cast.rs index 8bdd32ad6..f27dee3fd 100644 --- a/crates/hir_ty/src/chalk_cast.rs +++ b/crates/hir_ty/src/chalk_cast.rs @@ -1,14 +1,8 @@ //! Implementations of the Chalk `Cast` trait for our types. -use chalk_ir::{ - cast::{Cast, CastTo}, - interner::HasInterner, -}; +use chalk_ir::interner::HasInterner; -use crate::{ - AliasEq, CallableSig, DomainGoal, GenericArg, GenericArgData, Interner, PolyFnSig, - ReturnTypeImplTraits, TraitRef, Ty, WhereClause, -}; +use crate::{CallableSig, ReturnTypeImplTraits}; macro_rules! has_interner { ($t:ty) => { @@ -18,15 +12,5 @@ macro_rules! has_interner { }; } -macro_rules! transitive_impl { - ($a:ty, $b:ty, $c:ty) => { - impl CastTo<$c> for $a { - fn cast_to(self, interner: &Interner) -> $c { - self.cast::<$b>(interner).cast(interner) - } - } - }; -} - has_interner!(CallableSig); has_interner!(ReturnTypeImplTraits); diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 1d8184ef5..bf2da2d4a 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -38,7 +38,6 @@ use syntax::SmolStr; use super::{ DomainGoal, Guidance, InEnvironment, ProjectionTy, Solution, TraitEnvironment, TraitRef, Ty, - TypeWalk, }; use crate::{ db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic, diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 26dc6ceba..1f463a425 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs @@ -73,11 +73,11 @@ impl<'a> InferenceContext<'a> { // Pointer weakening and function to pointer match (from_ty.kind(&Interner), to_ty.kind(&Interner)) { // `*mut T` -> `*const T` - (TyKind::Raw(m1, inner), TyKind::Raw(m2 @ Mutability::Not, ..)) => { + (TyKind::Raw(_, inner), TyKind::Raw(m2 @ Mutability::Not, ..)) => { from_ty = TyKind::Raw(*m2, inner.clone()).intern(&Interner); } // `&mut T` -> `&T` - (TyKind::Ref(m1, lt, inner), TyKind::Ref(m2 @ Mutability::Not, ..)) => { + (TyKind::Ref(_, lt, inner), TyKind::Ref(m2 @ Mutability::Not, ..)) => { from_ty = TyKind::Ref(*m2, lt.clone(), inner.clone()).intern(&Interner); } // `&T` -> `*const T` diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 5f03079e8..cbbfa8b5c 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -24,7 +24,6 @@ use crate::{ utils::{generics, Generics}, AdtId, Binders, CallableDefId, FnPointer, FnSig, FnSubst, InEnvironment, Interner, ProjectionTyExt, Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyExt, TyKind, - TypeWalk, }; use super::{ diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index 3b9c4a495..a887e20b0 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -12,7 +12,7 @@ use super::{DomainGoal, InferenceContext}; use crate::{ fold_tys, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution, - Ty, TyExt, TyKind, TypeWalk, WhereClause, + Ty, TyExt, TyKind, WhereClause, }; impl<'a> InferenceContext<'a> { diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index f7af8b8aa..874c95411 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -1,8 +1,6 @@ //! The type system. We currently use this to infer types for completion, hover //! information and various assists. -#![allow(unused)] - #[allow(unused)] macro_rules! eprintln { ($($tt:tt)*) => { stdx::eprintln!($($tt)*) }; @@ -34,7 +32,6 @@ use std::sync::Arc; use base_db::salsa; use chalk_ir::{ - cast::{CastTo, Caster}, fold::{Fold, Shift}, interner::HasInterner, UintTy, diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 6584bcf34..8a22d9ea3 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -35,7 +35,7 @@ use crate::{ AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, DynTy, FnPointer, FnSig, FnSubst, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause, QuantifiedWhereClauses, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution, - TraitEnvironment, TraitRef, TraitRefExt, Ty, TyBuilder, TyKind, TypeWalk, WhereClause, + TraitEnvironment, TraitRef, TraitRefExt, Ty, TyBuilder, TyKind, WhereClause, }; #[derive(Debug)] diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 766880b14..be3e4f09a 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs @@ -6,11 +6,7 @@ use std::{iter, sync::Arc}; use arrayvec::ArrayVec; use base_db::CrateId; -use chalk_ir::{ - cast::Cast, - fold::{Fold, Folder}, - Fallible, Mutability, UniverseIndex, -}; +use chalk_ir::{cast::Cast, Mutability, UniverseIndex}; use hir_def::{ lang_item::LangItemTarget, nameres::DefMap, AssocContainerId, AssocItemId, FunctionId, GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId, @@ -25,9 +21,9 @@ use crate::{ primitive::{self, FloatTy, IntTy, UintTy}, static_lifetime, utils::all_super_traits, - AdtId, BoundVar, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId, + AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId, InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, TraitRefExt, Ty, TyBuilder, - TyExt, TyKind, TypeWalk, + TyExt, TyKind, }; /// This is used as a key for indexing impls. diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index 63d87fe61..1cda72d22 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs @@ -12,7 +12,7 @@ use crate::{ Solution, TraitRefExt, Ty, TyKind, WhereClause, }; -use self::chalk::{from_chalk, Interner, ToChalk}; +use self::chalk::Interner; pub(crate) mod chalk; @@ -101,8 +101,7 @@ pub(crate) fn trait_solve_query( // We currently don't deal with universes (I think / hope they're not yet // relevant for our use cases?) let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; - let solution = solve(db, krate, &u_canonical); - solution.map(|solution| solution_from_chalk(db, solution)) + solve(db, krate, &u_canonical) } fn solve( @@ -170,13 +169,6 @@ fn is_chalk_print() -> bool { std::env::var("CHALK_PRINT").is_ok() } -fn solution_from_chalk( - db: &dyn HirDatabase, - solution: chalk_solve::Solution, -) -> Solution { - solution -} - #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] pub enum FnTrait { FnOnce, diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index e2a54fd92..b8c390b2e 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use log::debug; -use chalk_ir::{fold::shift::Shift, interner::HasInterner, CanonicalVarKinds}; +use chalk_ir::{fold::shift::Shift, CanonicalVarKinds}; use chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait}; use base_db::{salsa::InternKey, CrateId}; diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 4abc0fbf2..7818f6387 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs @@ -3,16 +3,15 @@ //! Chalk (in both directions); plus some helper functions for more specialized //! conversions. -use chalk_ir::{cast::Cast, interner::HasInterner}; +use chalk_ir::cast::Cast; use chalk_solve::rust_ir; use base_db::salsa::InternKey; use hir_def::{GenericDefId, TypeAliasId}; use crate::{ - db::HirDatabase, static_lifetime, AliasTy, CallableDefId, Canonical, ConstrainedSubst, - DomainGoal, FnPointer, GenericArg, InEnvironment, OpaqueTy, ProjectionTy, ProjectionTyExt, - QuantifiedWhereClause, Substitution, TraitRef, Ty, TypeWalk, WhereClause, + db::HirDatabase, AliasTy, CallableDefId, ProjectionTyExt, QuantifiedWhereClause, Substitution, + Ty, WhereClause, }; use super::interner::*; diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index d26f5152c..5f6cb052a 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs @@ -1,6 +1,5 @@ //! Helper functions for working with def, which don't need to be a separate //! query, but can't be computed directly from `*Data` (ie, which need a `db`). -use std::sync::Arc; use chalk_ir::{fold::Shift, BoundVar, DebruijnIndex}; use hir_def::{ @@ -16,9 +15,7 @@ use hir_def::{ }; use hir_expand::name::{name, Name}; -use crate::{ - db::HirDatabase, Interner, Substitution, TraitRef, TraitRefExt, TyKind, TypeWalk, WhereClause, -}; +use crate::{db::HirDatabase, Interner, Substitution, TraitRef, TraitRefExt, TyKind, WhereClause}; fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec { let resolver = trait_.resolver(db); @@ -137,15 +134,6 @@ pub(super) fn associated_type_by_name_including_super_traits( }) } -/// Helper for mutating `Arc<[T]>` (i.e. `Arc::make_mut` for Arc slices). -/// The underlying values are cloned if there are other strong references. -pub(crate) fn make_mut_slice(a: &mut Arc<[T]>) -> &mut [T] { - if Arc::get_mut(a).is_none() { - *a = a.iter().cloned().collect(); - } - Arc::get_mut(a).unwrap() -} - pub(crate) fn generics(db: &dyn DefDatabase, def: GenericDefId) -> Generics { let parent_generics = parent_generic_def(db, def).map(|def| Box::new(generics(db, def))); Generics { def, params: db.generic_params(def), parent_generics } diff --git a/crates/hir_ty/src/walk.rs b/crates/hir_ty/src/walk.rs index 57343fd61..6ef1d5336 100644 --- a/crates/hir_ty/src/walk.rs +++ b/crates/hir_ty/src/walk.rs @@ -1,14 +1,11 @@ //! The `TypeWalk` trait (probably to be replaced by Chalk's `Fold` and //! `Visit`). -use std::mem; - -use chalk_ir::{interner::HasInterner, DebruijnIndex}; +use chalk_ir::interner::HasInterner; use crate::{ - utils::make_mut_slice, AliasEq, AliasTy, Binders, CallableSig, FnSubst, GenericArg, - GenericArgData, Interner, OpaqueTy, ProjectionTy, Substitution, TraitRef, Ty, TyKind, - WhereClause, + AliasEq, AliasTy, Binders, CallableSig, FnSubst, GenericArg, GenericArgData, Interner, + OpaqueTy, ProjectionTy, Substitution, TraitRef, Ty, TyKind, WhereClause, }; /// This allows walking structures that contain types to do something with those -- cgit v1.2.3