mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 06:41:48 +00:00
Move ProjectionTy methods to extension trait
This commit is contained in:
parent
8c96a7d81e
commit
788533d380
7 changed files with 43 additions and 32 deletions
|
@ -43,13 +43,13 @@ use crate::{db::HirDatabase, display::HirDisplay, utils::generics};
|
|||
|
||||
pub use autoderef::autoderef;
|
||||
pub use builder::TyBuilder;
|
||||
pub use chalk_ext::TyExt;
|
||||
pub use chalk_ext::{ProjectionTyExt, TyExt};
|
||||
pub use infer::{could_unify, InferenceResult, InferenceVar};
|
||||
pub use lower::{
|
||||
associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode,
|
||||
TyDefId, TyLoweringContext, ValueTyDefId,
|
||||
};
|
||||
pub use traits::TraitEnvironment;
|
||||
pub use traits::{chalk::Interner, TraitEnvironment};
|
||||
pub use types::*;
|
||||
pub use walk::TypeWalk;
|
||||
|
||||
|
@ -57,8 +57,6 @@ pub use chalk_ir::{
|
|||
cast::Cast, AdtId, BoundVar, DebruijnIndex, Mutability, Safety, Scalar, TyVariableKind,
|
||||
};
|
||||
|
||||
pub use crate::traits::chalk::Interner;
|
||||
|
||||
pub type ForeignDefId = chalk_ir::ForeignDefId<Interner>;
|
||||
pub type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
|
||||
pub type FnDefId = chalk_ir::FnDefId<Interner>;
|
||||
|
@ -76,26 +74,6 @@ pub type LifetimeOutlives = chalk_ir::LifetimeOutlives<Interner>;
|
|||
|
||||
pub type ChalkTraitId = chalk_ir::TraitId<Interner>;
|
||||
|
||||
impl ProjectionTy {
|
||||
pub fn trait_ref(&self, db: &dyn HirDatabase) -> TraitRef {
|
||||
TraitRef {
|
||||
trait_id: to_chalk_trait_id(self.trait_(db)),
|
||||
substitution: self.substitution.clone(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn self_type_parameter(&self, interner: &Interner) -> &Ty {
|
||||
&self.substitution.interned()[0].assert_ty_ref(interner)
|
||||
}
|
||||
|
||||
fn trait_(&self, db: &dyn HirDatabase) -> TraitId {
|
||||
match from_assoc_type_id(self.associated_ty_id).lookup(db.upcast()).container {
|
||||
AssocContainerId::TraitId(it) => it,
|
||||
_ => panic!("projection ty without parent trait"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub type FnSig = chalk_ir::FnSig<Interner>;
|
||||
|
||||
impl Substitution {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue