Skip to content

Commit

Permalink
Remove unused
Browse files Browse the repository at this point in the history
  • Loading branch information
flodiebold committed Apr 8, 2021
1 parent 8040f4a commit d992736
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 69 deletions.
2 changes: 1 addition & 1 deletion crates/hir_ty/src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
Expand Down
20 changes: 2 additions & 18 deletions crates/hir_ty/src/chalk_cast.rs
Original file line number Diff line number Diff line change
@@ -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) => {
Expand All @@ -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);
1 change: 0 additions & 1 deletion crates/hir_ty/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions crates/hir_ty/src/infer/coerce.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
1 change: 0 additions & 1 deletion crates/hir_ty/src/infer/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
2 changes: 1 addition & 1 deletion crates/hir_ty/src/infer/unify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
3 changes: 0 additions & 3 deletions crates/hir_ty/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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)*) };
Expand Down Expand Up @@ -34,7 +32,6 @@ use std::sync::Arc;

use base_db::salsa;
use chalk_ir::{
cast::{CastTo, Caster},
fold::{Fold, Shift},
interner::HasInterner,
UintTy,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir_ty/src/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
10 changes: 3 additions & 7 deletions crates/hir_ty/src/method_resolution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
12 changes: 2 additions & 10 deletions crates/hir_ty/src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<Interner>,
) -> Solution {
solution
}

#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
pub enum FnTrait {
FnOnce,
Expand Down
2 changes: 1 addition & 1 deletion crates/hir_ty/src/traits/chalk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down
7 changes: 3 additions & 4 deletions crates/hir_ty/src/traits/chalk/mapping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::*;
Expand Down
14 changes: 1 addition & 13 deletions crates/hir_ty/src/utils.rs
Original file line number Diff line number Diff line change
@@ -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::{
Expand All @@ -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<TraitId> {
let resolver = trait_.resolver(db);
Expand Down Expand Up @@ -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<T: Clone>(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 }
Expand Down
9 changes: 3 additions & 6 deletions crates/hir_ty/src/walk.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit d992736

Please sign in to comment.