aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/traits/chalk.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty/traits/chalk.rs')
-rw-r--r--crates/ra_hir/src/ty/traits/chalk.rs29
1 files changed, 15 insertions, 14 deletions
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs
index 88785f305..1a93e5e50 100644
--- a/crates/ra_hir/src/ty/traits/chalk.rs
+++ b/crates/ra_hir/src/ty/traits/chalk.rs
@@ -9,6 +9,7 @@ use chalk_ir::{
9}; 9};
10use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; 10use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum};
11 11
12use hir_def::lang_item::LangItemTarget;
12use hir_expand::name; 13use hir_expand::name;
13 14
14use ra_db::salsa::{InternId, InternKey}; 15use ra_db::salsa::{InternId, InternKey};
@@ -18,7 +19,7 @@ use crate::{
18 db::HirDatabase, 19 db::HirDatabase,
19 ty::display::HirDisplay, 20 ty::display::HirDisplay,
20 ty::{ApplicationTy, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk}, 21 ty::{ApplicationTy, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk},
21 Crate, GenericDef, HasBody, ImplBlock, Trait, TypeAlias, 22 Crate, GenericDef, ImplBlock, Trait, TypeAlias,
22}; 23};
23 24
24/// This represents a trait whose name we could not resolve. 25/// This represents a trait whose name we could not resolve.
@@ -714,7 +715,7 @@ fn closure_fn_trait_impl_datum(
714 let fn_once_trait = get_fn_trait(db, krate, super::FnTrait::FnOnce)?; 715 let fn_once_trait = get_fn_trait(db, krate, super::FnTrait::FnOnce)?;
715 fn_once_trait.associated_type_by_name(db, &name::OUTPUT_TYPE)?; 716 fn_once_trait.associated_type_by_name(db, &name::OUTPUT_TYPE)?;
716 717
717 let num_args: u16 = match &data.def.body(db)[data.expr] { 718 let num_args: u16 = match &db.body(data.def.into())[data.expr] {
718 crate::expr::Expr::Lambda { args, .. } => args.len() as u16, 719 crate::expr::Expr::Lambda { args, .. } => args.len() as u16,
719 _ => { 720 _ => {
720 log::warn!("closure for closure type {:?} not found", data); 721 log::warn!("closure for closure type {:?} not found", data);
@@ -804,7 +805,7 @@ fn closure_fn_trait_output_assoc_ty_value(
804) -> Arc<AssociatedTyValue<ChalkIr>> { 805) -> Arc<AssociatedTyValue<ChalkIr>> {
805 let impl_id = Impl::ClosureFnTraitImpl(data.clone()).to_chalk(db); 806 let impl_id = Impl::ClosureFnTraitImpl(data.clone()).to_chalk(db);
806 807
807 let num_args: u16 = match &data.def.body(db)[data.expr] { 808 let num_args: u16 = match &db.body(data.def.into())[data.expr] {
808 crate::expr::Expr::Lambda { args, .. } => args.len() as u16, 809 crate::expr::Expr::Lambda { args, .. } => args.len() as u16,
809 _ => { 810 _ => {
810 log::warn!("closure for closure type {:?} not found", data); 811 log::warn!("closure for closure type {:?} not found", data);
@@ -832,9 +833,9 @@ fn closure_fn_trait_output_assoc_ty_value(
832} 833}
833 834
834fn get_fn_trait(db: &impl HirDatabase, krate: Crate, fn_trait: super::FnTrait) -> Option<Trait> { 835fn get_fn_trait(db: &impl HirDatabase, krate: Crate, fn_trait: super::FnTrait) -> Option<Trait> {
835 let target = db.lang_item(krate, fn_trait.lang_item_name().into())?; 836 let target = db.lang_item(krate.crate_id, fn_trait.lang_item_name().into())?;
836 match target { 837 match target {
837 crate::lang_item::LangItemTarget::Trait(t) => Some(t), 838 LangItemTarget::TraitId(t) => Some(t.into()),
838 _ => None, 839 _ => None,
839 } 840 }
840} 841}
@@ -846,38 +847,38 @@ fn id_to_chalk<T: InternKey>(salsa_id: T) -> chalk_ir::RawId {
846 chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() } 847 chalk_ir::RawId { index: salsa_id.as_intern_id().as_u32() }
847} 848}
848 849
849impl From<chalk_ir::StructId> for crate::ids::TypeCtorId { 850impl From<chalk_ir::StructId> for crate::ty::TypeCtorId {
850 fn from(struct_id: chalk_ir::StructId) -> Self { 851 fn from(struct_id: chalk_ir::StructId) -> Self {
851 id_from_chalk(struct_id.0) 852 id_from_chalk(struct_id.0)
852 } 853 }
853} 854}
854 855
855impl From<crate::ids::TypeCtorId> for chalk_ir::StructId { 856impl From<crate::ty::TypeCtorId> for chalk_ir::StructId {
856 fn from(type_ctor_id: crate::ids::TypeCtorId) -> Self { 857 fn from(type_ctor_id: crate::ty::TypeCtorId) -> Self {
857 chalk_ir::StructId(id_to_chalk(type_ctor_id)) 858 chalk_ir::StructId(id_to_chalk(type_ctor_id))
858 } 859 }
859} 860}
860 861
861impl From<chalk_ir::ImplId> for crate::ids::GlobalImplId { 862impl From<chalk_ir::ImplId> for crate::ty::traits::GlobalImplId {
862 fn from(impl_id: chalk_ir::ImplId) -> Self { 863 fn from(impl_id: chalk_ir::ImplId) -> Self {
863 id_from_chalk(impl_id.0) 864 id_from_chalk(impl_id.0)
864 } 865 }
865} 866}
866 867
867impl From<crate::ids::GlobalImplId> for chalk_ir::ImplId { 868impl From<crate::ty::traits::GlobalImplId> for chalk_ir::ImplId {
868 fn from(impl_id: crate::ids::GlobalImplId) -> Self { 869 fn from(impl_id: crate::ty::traits::GlobalImplId) -> Self {
869 chalk_ir::ImplId(id_to_chalk(impl_id)) 870 chalk_ir::ImplId(id_to_chalk(impl_id))
870 } 871 }
871} 872}
872 873
873impl From<chalk_rust_ir::AssociatedTyValueId> for crate::ids::AssocTyValueId { 874impl From<chalk_rust_ir::AssociatedTyValueId> for crate::ty::traits::AssocTyValueId {
874 fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self { 875 fn from(id: chalk_rust_ir::AssociatedTyValueId) -> Self {
875 id_from_chalk(id.0) 876 id_from_chalk(id.0)
876 } 877 }
877} 878}
878 879
879impl From<crate::ids::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId { 880impl From<crate::ty::traits::AssocTyValueId> for chalk_rust_ir::AssociatedTyValueId {
880 fn from(assoc_ty_value_id: crate::ids::AssocTyValueId) -> Self { 881 fn from(assoc_ty_value_id: crate::ty::traits::AssocTyValueId) -> Self {
881 chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id)) 882 chalk_rust_ir::AssociatedTyValueId(id_to_chalk(assoc_ty_value_id))
882 } 883 }
883} 884}