mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Add and start using TraitRef and ProjectionTy builders
This commit is contained in:
parent
2ead65190e
commit
cd227f581e
6 changed files with 48 additions and 39 deletions
|
@ -19,10 +19,9 @@ use crate::{
|
|||
db::HirDatabase,
|
||||
from_foreign_def_id,
|
||||
primitive::{self, FloatTy, IntTy, UintTy},
|
||||
to_chalk_trait_id,
|
||||
utils::all_super_traits,
|
||||
AdtId, Canonical, CanonicalVarKinds, DebruijnIndex, FnPointer, FnSig, ForeignDefId,
|
||||
InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, TraitRef, Ty, TyKind,
|
||||
InEnvironment, Interner, Scalar, Substitution, TraitEnvironment, Ty, TyBuilder, TyKind,
|
||||
TypeWalk,
|
||||
};
|
||||
|
||||
|
@ -813,7 +812,7 @@ fn generic_implements_goal(
|
|||
self_ty: Canonical<Ty>,
|
||||
) -> Canonical<InEnvironment<super::DomainGoal>> {
|
||||
let mut kinds = self_ty.binders.interned().to_vec();
|
||||
let substs = super::Substitution::build_for_def(db, trait_)
|
||||
let trait_ref = TyBuilder::trait_ref(db, trait_)
|
||||
.push(self_ty.value)
|
||||
.fill_with_bound_vars(DebruijnIndex::INNERMOST, kinds.len())
|
||||
.build();
|
||||
|
@ -822,9 +821,8 @@ fn generic_implements_goal(
|
|||
chalk_ir::VariableKind::Ty(chalk_ir::TyVariableKind::General),
|
||||
UniverseIndex::ROOT,
|
||||
))
|
||||
.take(substs.len(&Interner) - 1),
|
||||
.take(trait_ref.substitution.len(&Interner) - 1),
|
||||
);
|
||||
let trait_ref = TraitRef { trait_id: to_chalk_trait_id(trait_), substitution: substs };
|
||||
let obligation = trait_ref.cast(&Interner);
|
||||
Canonical {
|
||||
binders: CanonicalVarKinds::from_iter(&Interner, kinds),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue