mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Remove some unused methods, move some to types.rs
This commit is contained in:
parent
738174671a
commit
b443e5304e
2 changed files with 15 additions and 29 deletions
|
@ -99,15 +99,6 @@ where
|
||||||
Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE))
|
Binders::empty(&Interner, value.shifted_in_from(DebruijnIndex::ONE))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: TypeWalk> Binders<T> {
|
|
||||||
/// Substitutes all variables.
|
|
||||||
pub fn substitute(self, interner: &Interner, subst: &Substitution) -> T {
|
|
||||||
let (value, binders) = self.into_value_and_skipped_binders();
|
|
||||||
assert_eq!(subst.len(interner), binders.len(interner));
|
|
||||||
value.subst_bound_vars(subst)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
|
pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
|
||||||
Binders::new(
|
Binders::new(
|
||||||
VariableKinds::from_iter(
|
VariableKinds::from_iter(
|
||||||
|
@ -120,31 +111,11 @@ pub fn make_only_type_binders<T>(num_vars: usize, value: T) -> Binders<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl TraitRef {
|
impl TraitRef {
|
||||||
pub fn self_type_parameter(&self, interner: &Interner) -> &Ty {
|
|
||||||
&self.substitution.at(interner, 0).assert_ty_ref(interner)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn hir_trait_id(&self) -> TraitId {
|
pub fn hir_trait_id(&self) -> TraitId {
|
||||||
from_chalk_trait_id(self.trait_id)
|
from_chalk_trait_id(self.trait_id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WhereClause {
|
|
||||||
pub fn is_implemented(&self) -> bool {
|
|
||||||
matches!(self, WhereClause::Implemented(_))
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn trait_ref(&self, db: &dyn HirDatabase) -> Option<TraitRef> {
|
|
||||||
match self {
|
|
||||||
WhereClause::Implemented(tr) => Some(tr.clone()),
|
|
||||||
WhereClause::AliasEq(AliasEq { alias: AliasTy::Projection(proj), .. }) => {
|
|
||||||
Some(proj.trait_ref(db))
|
|
||||||
}
|
|
||||||
WhereClause::AliasEq(_) => None,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Canonical<T> {
|
impl<T> Canonical<T> {
|
||||||
pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self {
|
pub fn new(value: T, kinds: impl IntoIterator<Item = TyVariableKind>) -> Self {
|
||||||
let kinds = kinds.into_iter().map(|tk| {
|
let kinds = kinds.into_iter().map(|tk| {
|
||||||
|
|
|
@ -360,6 +360,15 @@ impl<T: Clone> Binders<&T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<T: TypeWalk> Binders<T> {
|
||||||
|
/// Substitutes all variables.
|
||||||
|
pub fn substitute(self, interner: &Interner, subst: &Substitution) -> T {
|
||||||
|
let (value, binders) = self.into_value_and_skipped_binders();
|
||||||
|
assert_eq!(subst.len(interner), binders.len(interner));
|
||||||
|
value.subst_bound_vars(subst)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<T: std::fmt::Debug> std::fmt::Debug for Binders<T> {
|
impl<T: std::fmt::Debug> std::fmt::Debug for Binders<T> {
|
||||||
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
fn fmt(&self, fmt: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
|
||||||
let Binders { ref binders, ref value } = *self;
|
let Binders { ref binders, ref value } = *self;
|
||||||
|
@ -375,6 +384,12 @@ pub struct TraitRef {
|
||||||
pub substitution: Substitution,
|
pub substitution: Substitution,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl TraitRef {
|
||||||
|
pub fn self_type_parameter(&self, interner: &Interner) -> &Ty {
|
||||||
|
&self.substitution.at(interner, 0).assert_ty_ref(interner)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Like `generics::WherePredicate`, but with resolved types: A condition on the
|
/// Like `generics::WherePredicate`, but with resolved types: A condition on the
|
||||||
/// parameters of a generic item.
|
/// parameters of a generic item.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue