aboutsummaryrefslogtreecommitdiff
path: root/crates/hir/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir/src')
-rw-r--r--crates/hir/src/lib.rs24
1 files changed, 8 insertions, 16 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs
index 682d49a21..15f46f720 100644
--- a/crates/hir/src/lib.rs
+++ b/crates/hir/src/lib.rs
@@ -55,11 +55,10 @@ use hir_ty::{
55 autoderef, could_unify, 55 autoderef, could_unify,
56 method_resolution::{self, TyFingerprint}, 56 method_resolution::{self, TyFingerprint},
57 primitive::UintTy, 57 primitive::UintTy,
58 to_assoc_type_id,
59 traits::{FnTrait, Solution, SolutionVariables}, 58 traits::{FnTrait, Solution, SolutionVariables},
60 AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast, 59 AliasEq, AliasTy, BoundVar, CallableDefId, CallableSig, Canonical, CanonicalVarKinds, Cast,
61 DebruijnIndex, InEnvironment, Interner, ProjectionTy, QuantifiedWhereClause, Scalar, 60 DebruijnIndex, InEnvironment, Interner, QuantifiedWhereClause, Scalar, Substitution,
62 Substitution, TraitEnvironment, Ty, TyBuilder, TyDefId, TyKind, TyVariableKind, WhereClause, 61 TraitEnvironment, Ty, TyBuilder, TyDefId, TyKind, TyVariableKind, WhereClause,
63}; 62};
64use itertools::Itertools; 63use itertools::Itertools;
65use rustc_hash::FxHashSet; 64use rustc_hash::FxHashSet;
@@ -1785,13 +1784,10 @@ impl Type {
1785 } 1784 }
1786 1785
1787 pub fn impls_trait(&self, db: &dyn HirDatabase, trait_: Trait, args: &[Type]) -> bool { 1786 pub fn impls_trait(&self, db: &dyn HirDatabase, trait_: Trait, args: &[Type]) -> bool {
1788 let trait_ref = hir_ty::TraitRef { 1787 let trait_ref = TyBuilder::trait_ref(db, trait_.id)
1789 trait_id: hir_ty::to_chalk_trait_id(trait_.id), 1788 .push(self.ty.clone())
1790 substitution: Substitution::build_for_def(db, trait_.id) 1789 .fill(args.iter().map(|t| t.ty.clone()))
1791 .push(self.ty.clone()) 1790 .build();
1792 .fill(args.iter().map(|t| t.ty.clone()))
1793 .build(),
1794 };
1795 1791
1796 let goal = Canonical { 1792 let goal = Canonical {
1797 value: hir_ty::InEnvironment::new(self.env.env.clone(), trait_ref.cast(&Interner)), 1793 value: hir_ty::InEnvironment::new(self.env.env.clone(), trait_ref.cast(&Interner)),
@@ -1804,11 +1800,10 @@ impl Type {
1804 pub fn normalize_trait_assoc_type( 1800 pub fn normalize_trait_assoc_type(
1805 &self, 1801 &self,
1806 db: &dyn HirDatabase, 1802 db: &dyn HirDatabase,
1807 trait_: Trait,
1808 args: &[Type], 1803 args: &[Type],
1809 alias: TypeAlias, 1804 alias: TypeAlias,
1810 ) -> Option<Type> { 1805 ) -> Option<Type> {
1811 let subst = Substitution::build_for_def(db, trait_.id) 1806 let projection = TyBuilder::assoc_type_projection(db, alias.id)
1812 .push(self.ty.clone()) 1807 .push(self.ty.clone())
1813 .fill(args.iter().map(|t| t.ty.clone())) 1808 .fill(args.iter().map(|t| t.ty.clone()))
1814 .build(); 1809 .build();
@@ -1816,10 +1811,7 @@ impl Type {
1816 InEnvironment::new( 1811 InEnvironment::new(
1817 self.env.env.clone(), 1812 self.env.env.clone(),
1818 AliasEq { 1813 AliasEq {
1819 alias: AliasTy::Projection(ProjectionTy { 1814 alias: AliasTy::Projection(projection),
1820 associated_ty_id: to_assoc_type_id(alias.id),
1821 substitution: subst,
1822 }),
1823 ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0)) 1815 ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0))
1824 .intern(&Interner), 1816 .intern(&Interner),
1825 } 1817 }