mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Remove unused
This commit is contained in:
parent
8040f4a5e3
commit
d992736e79
14 changed files with 20 additions and 69 deletions
|
@ -14,7 +14,7 @@ use smallvec::SmallVec;
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase, primitive, to_assoc_type_id, to_chalk_trait_id, utils::generics, Binders,
|
db::HirDatabase, primitive, to_assoc_type_id, to_chalk_trait_id, utils::generics, Binders,
|
||||||
CallableSig, FnPointer, FnSig, FnSubst, GenericArg, Interner, ProjectionTy, Substitution,
|
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`.
|
/// This is a builder for `Ty` or anything that needs a `Substitution`.
|
||||||
|
|
|
@ -1,14 +1,8 @@
|
||||||
//! Implementations of the Chalk `Cast` trait for our types.
|
//! Implementations of the Chalk `Cast` trait for our types.
|
||||||
|
|
||||||
use chalk_ir::{
|
use chalk_ir::interner::HasInterner;
|
||||||
cast::{Cast, CastTo},
|
|
||||||
interner::HasInterner,
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{CallableSig, ReturnTypeImplTraits};
|
||||||
AliasEq, CallableSig, DomainGoal, GenericArg, GenericArgData, Interner, PolyFnSig,
|
|
||||||
ReturnTypeImplTraits, TraitRef, Ty, WhereClause,
|
|
||||||
};
|
|
||||||
|
|
||||||
macro_rules! has_interner {
|
macro_rules! has_interner {
|
||||||
($t:ty) => {
|
($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!(CallableSig);
|
||||||
has_interner!(ReturnTypeImplTraits);
|
has_interner!(ReturnTypeImplTraits);
|
||||||
|
|
|
@ -38,7 +38,6 @@ use syntax::SmolStr;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
DomainGoal, Guidance, InEnvironment, ProjectionTy, Solution, TraitEnvironment, TraitRef, Ty,
|
DomainGoal, Guidance, InEnvironment, ProjectionTy, Solution, TraitEnvironment, TraitRef, Ty,
|
||||||
TypeWalk,
|
|
||||||
};
|
};
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic,
|
db::HirDatabase, fold_tys, infer::diagnostics::InferenceDiagnostic,
|
||||||
|
|
|
@ -73,11 +73,11 @@ impl<'a> InferenceContext<'a> {
|
||||||
// Pointer weakening and function to pointer
|
// Pointer weakening and function to pointer
|
||||||
match (from_ty.kind(&Interner), to_ty.kind(&Interner)) {
|
match (from_ty.kind(&Interner), to_ty.kind(&Interner)) {
|
||||||
// `*mut T` -> `*const T`
|
// `*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);
|
from_ty = TyKind::Raw(*m2, inner.clone()).intern(&Interner);
|
||||||
}
|
}
|
||||||
// `&mut T` -> `&T`
|
// `&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);
|
from_ty = TyKind::Ref(*m2, lt.clone(), inner.clone()).intern(&Interner);
|
||||||
}
|
}
|
||||||
// `&T` -> `*const T`
|
// `&T` -> `*const T`
|
||||||
|
|
|
@ -24,7 +24,6 @@ use crate::{
|
||||||
utils::{generics, Generics},
|
utils::{generics, Generics},
|
||||||
AdtId, Binders, CallableDefId, FnPointer, FnSig, FnSubst, InEnvironment, Interner,
|
AdtId, Binders, CallableDefId, FnPointer, FnSig, FnSubst, InEnvironment, Interner,
|
||||||
ProjectionTyExt, Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyExt, TyKind,
|
ProjectionTyExt, Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyExt, TyKind,
|
||||||
TypeWalk,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|
|
@ -12,7 +12,7 @@ use super::{DomainGoal, InferenceContext};
|
||||||
use crate::{
|
use crate::{
|
||||||
fold_tys, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds,
|
fold_tys, static_lifetime, AliasEq, AliasTy, BoundVar, Canonical, CanonicalVarKinds,
|
||||||
DebruijnIndex, FnPointer, FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution,
|
DebruijnIndex, FnPointer, FnSubst, InEnvironment, InferenceVar, Interner, Scalar, Substitution,
|
||||||
Ty, TyExt, TyKind, TypeWalk, WhereClause,
|
Ty, TyExt, TyKind, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
impl<'a> InferenceContext<'a> {
|
impl<'a> InferenceContext<'a> {
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
//! The type system. We currently use this to infer types for completion, hover
|
//! The type system. We currently use this to infer types for completion, hover
|
||||||
//! information and various assists.
|
//! information and various assists.
|
||||||
|
|
||||||
#![allow(unused)]
|
|
||||||
|
|
||||||
#[allow(unused)]
|
#[allow(unused)]
|
||||||
macro_rules! eprintln {
|
macro_rules! eprintln {
|
||||||
($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
|
($($tt:tt)*) => { stdx::eprintln!($($tt)*) };
|
||||||
|
@ -34,7 +32,6 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use base_db::salsa;
|
use base_db::salsa;
|
||||||
use chalk_ir::{
|
use chalk_ir::{
|
||||||
cast::{CastTo, Caster},
|
|
||||||
fold::{Fold, Shift},
|
fold::{Fold, Shift},
|
||||||
interner::HasInterner,
|
interner::HasInterner,
|
||||||
UintTy,
|
UintTy,
|
||||||
|
|
|
@ -35,7 +35,7 @@ use crate::{
|
||||||
AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, DynTy, FnPointer, FnSig,
|
AliasEq, AliasTy, Binders, BoundVar, CallableSig, DebruijnIndex, DynTy, FnPointer, FnSig,
|
||||||
FnSubst, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause,
|
FnSubst, ImplTraitId, OpaqueTy, PolyFnSig, ProjectionTy, QuantifiedWhereClause,
|
||||||
QuantifiedWhereClauses, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution,
|
QuantifiedWhereClauses, ReturnTypeImplTrait, ReturnTypeImplTraits, Substitution,
|
||||||
TraitEnvironment, TraitRef, TraitRefExt, Ty, TyBuilder, TyKind, TypeWalk, WhereClause,
|
TraitEnvironment, TraitRef, TraitRefExt, Ty, TyBuilder, TyKind, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
|
|
@ -6,11 +6,7 @@ use std::{iter, sync::Arc};
|
||||||
|
|
||||||
use arrayvec::ArrayVec;
|
use arrayvec::ArrayVec;
|
||||||
use base_db::CrateId;
|
use base_db::CrateId;
|
||||||
use chalk_ir::{
|
use chalk_ir::{cast::Cast, Mutability, UniverseIndex};
|
||||||
cast::Cast,
|
|
||||||
fold::{Fold, Folder},
|
|
||||||
Fallible, Mutability, UniverseIndex,
|
|
||||||
};
|
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
lang_item::LangItemTarget, nameres::DefMap, AssocContainerId, AssocItemId, FunctionId,
|
lang_item::LangItemTarget, nameres::DefMap, AssocContainerId, AssocItemId, FunctionId,
|
||||||
GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId,
|
GenericDefId, HasModule, ImplId, Lookup, ModuleId, TraitId,
|
||||||
|
@ -25,9 +21,9 @@ use crate::{
|
||||||
primitive::{self, FloatTy, IntTy, UintTy},
|
primitive::{self, FloatTy, IntTy, UintTy},
|
||||||
static_lifetime,
|
static_lifetime,
|
||||||
utils::all_super_traits,
|
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,
|
InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, TraitRefExt, Ty, TyBuilder,
|
||||||
TyExt, TyKind, TypeWalk,
|
TyExt, TyKind,
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This is used as a key for indexing impls.
|
/// This is used as a key for indexing impls.
|
||||||
|
|
|
@ -12,7 +12,7 @@ use crate::{
|
||||||
Solution, TraitRefExt, Ty, TyKind, WhereClause,
|
Solution, TraitRefExt, Ty, TyKind, WhereClause,
|
||||||
};
|
};
|
||||||
|
|
||||||
use self::chalk::{from_chalk, Interner, ToChalk};
|
use self::chalk::Interner;
|
||||||
|
|
||||||
pub(crate) mod chalk;
|
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
|
// We currently don't deal with universes (I think / hope they're not yet
|
||||||
// relevant for our use cases?)
|
// relevant for our use cases?)
|
||||||
let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 };
|
let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 };
|
||||||
let solution = solve(db, krate, &u_canonical);
|
solve(db, krate, &u_canonical)
|
||||||
solution.map(|solution| solution_from_chalk(db, solution))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn solve(
|
fn solve(
|
||||||
|
@ -170,13 +169,6 @@ fn is_chalk_print() -> bool {
|
||||||
std::env::var("CHALK_PRINT").is_ok()
|
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)]
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum FnTrait {
|
pub enum FnTrait {
|
||||||
FnOnce,
|
FnOnce,
|
||||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
||||||
|
|
||||||
use log::debug;
|
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 chalk_solve::rust_ir::{self, OpaqueTyDatumBound, WellKnownTrait};
|
||||||
|
|
||||||
use base_db::{salsa::InternKey, CrateId};
|
use base_db::{salsa::InternKey, CrateId};
|
||||||
|
|
|
@ -3,16 +3,15 @@
|
||||||
//! Chalk (in both directions); plus some helper functions for more specialized
|
//! Chalk (in both directions); plus some helper functions for more specialized
|
||||||
//! conversions.
|
//! conversions.
|
||||||
|
|
||||||
use chalk_ir::{cast::Cast, interner::HasInterner};
|
use chalk_ir::cast::Cast;
|
||||||
use chalk_solve::rust_ir;
|
use chalk_solve::rust_ir;
|
||||||
|
|
||||||
use base_db::salsa::InternKey;
|
use base_db::salsa::InternKey;
|
||||||
use hir_def::{GenericDefId, TypeAliasId};
|
use hir_def::{GenericDefId, TypeAliasId};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
db::HirDatabase, static_lifetime, AliasTy, CallableDefId, Canonical, ConstrainedSubst,
|
db::HirDatabase, AliasTy, CallableDefId, ProjectionTyExt, QuantifiedWhereClause, Substitution,
|
||||||
DomainGoal, FnPointer, GenericArg, InEnvironment, OpaqueTy, ProjectionTy, ProjectionTyExt,
|
Ty, WhereClause,
|
||||||
QuantifiedWhereClause, Substitution, TraitRef, Ty, TypeWalk, WhereClause,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::interner::*;
|
use super::interner::*;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
//! Helper functions for working with def, which don't need to be a separate
|
//! 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`).
|
//! 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 chalk_ir::{fold::Shift, BoundVar, DebruijnIndex};
|
||||||
use hir_def::{
|
use hir_def::{
|
||||||
|
@ -16,9 +15,7 @@ use hir_def::{
|
||||||
};
|
};
|
||||||
use hir_expand::name::{name, Name};
|
use hir_expand::name::{name, Name};
|
||||||
|
|
||||||
use crate::{
|
use crate::{db::HirDatabase, Interner, Substitution, TraitRef, TraitRefExt, TyKind, WhereClause};
|
||||||
db::HirDatabase, Interner, Substitution, TraitRef, TraitRefExt, TyKind, TypeWalk, WhereClause,
|
|
||||||
};
|
|
||||||
|
|
||||||
fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<TraitId> {
|
fn direct_super_traits(db: &dyn DefDatabase, trait_: TraitId) -> Vec<TraitId> {
|
||||||
let resolver = trait_.resolver(db);
|
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<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 {
|
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)));
|
let parent_generics = parent_generic_def(db, def).map(|def| Box::new(generics(db, def)));
|
||||||
Generics { def, params: db.generic_params(def), parent_generics }
|
Generics { def, params: db.generic_params(def), parent_generics }
|
||||||
|
|
|
@ -1,14 +1,11 @@
|
||||||
//! The `TypeWalk` trait (probably to be replaced by Chalk's `Fold` and
|
//! The `TypeWalk` trait (probably to be replaced by Chalk's `Fold` and
|
||||||
//! `Visit`).
|
//! `Visit`).
|
||||||
|
|
||||||
use std::mem;
|
use chalk_ir::interner::HasInterner;
|
||||||
|
|
||||||
use chalk_ir::{interner::HasInterner, DebruijnIndex};
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
utils::make_mut_slice, AliasEq, AliasTy, Binders, CallableSig, FnSubst, GenericArg,
|
AliasEq, AliasTy, Binders, CallableSig, FnSubst, GenericArg, GenericArgData, Interner,
|
||||||
GenericArgData, Interner, OpaqueTy, ProjectionTy, Substitution, TraitRef, Ty, TyKind,
|
OpaqueTy, ProjectionTy, Substitution, TraitRef, Ty, TyKind, WhereClause,
|
||||||
WhereClause,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/// This allows walking structures that contain types to do something with those
|
/// This allows walking structures that contain types to do something with those
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue