aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-07-16 12:17:53 +0100
committerGitHub <[email protected]>2020-07-16 12:17:53 +0100
commit468982e45a035c271c40bea9b17c2c202a7efc75 (patch)
tree96f00583eaa8659a21960fa5fc4717d4d9bf0962
parent8a880230a522b34a0ba7f434f4ad3acdfd3448b1 (diff)
parentb5ce84b17023d27f4e96ec7911aca712db0e000b (diff)
Merge #5405
5405: Align CallableDefId naming with other ids r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--crates/ra_hir/src/code_model.rs4
-rw-r--r--crates/ra_hir/src/lib.rs2
-rw-r--r--crates/ra_hir_ty/src/db.rs12
-rw-r--r--crates/ra_hir_ty/src/diagnostics/unsafe_check.rs4
-rw-r--r--crates/ra_hir_ty/src/display.rs10
-rw-r--r--crates/ra_hir_ty/src/infer/expr.rs6
-rw-r--r--crates/ra_hir_ty/src/lib.rs14
-rw-r--r--crates/ra_hir_ty/src/lower.rs30
-rw-r--r--crates/ra_hir_ty/src/traits/chalk.rs10
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/mapping.rs6
-rw-r--r--crates/ra_hir_ty/src/traits/chalk/tls.rs24
-rw-r--r--crates/ra_ide/src/call_hierarchy.rs2
-rw-r--r--crates/ra_ide/src/call_info.rs6
-rw-r--r--crates/ra_ide/src/inlay_hints.rs6
14 files changed, 69 insertions, 67 deletions
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs
index 42c9ca189..9891b0785 100644
--- a/crates/ra_hir/src/code_model.rs
+++ b/crates/ra_hir/src/code_model.rs
@@ -40,7 +40,7 @@ use stdx::impl_from;
40use crate::{ 40use crate::{
41 db::{DefDatabase, HirDatabase}, 41 db::{DefDatabase, HirDatabase},
42 has_source::HasSource, 42 has_source::HasSource,
43 CallableDef, HirDisplay, InFile, Name, 43 CallableDefId, HirDisplay, InFile, Name,
44}; 44};
45 45
46/// hir::Crate describes a single crate. It's the main interface with which 46/// hir::Crate describes a single crate. It's the main interface with which
@@ -1226,7 +1226,7 @@ impl Type {
1226 } 1226 }
1227 1227
1228 // FIXME: this method is broken, as it doesn't take closures into account. 1228 // FIXME: this method is broken, as it doesn't take closures into account.
1229 pub fn as_callable(&self) -> Option<CallableDef> { 1229 pub fn as_callable(&self) -> Option<CallableDefId> {
1230 Some(self.ty.value.as_callable()?.0) 1230 Some(self.ty.value.as_callable()?.0)
1231 } 1231 }
1232 1232
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs
index 7d9b174b4..cf7134923 100644
--- a/crates/ra_hir/src/lib.rs
+++ b/crates/ra_hir/src/lib.rs
@@ -55,4 +55,4 @@ pub use hir_expand::{
55 hygiene::Hygiene, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId, 55 hygiene::Hygiene, name::Name, HirFileId, InFile, MacroCallId, MacroCallLoc, MacroDefId,
56 MacroFile, Origin, 56 MacroFile, Origin,
57}; 57};
58pub use hir_ty::{display::HirDisplay, CallableDef}; 58pub use hir_ty::{display::HirDisplay, CallableDefId};
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs
index 608bab1b1..c773adc67 100644
--- a/crates/ra_hir_ty/src/db.rs
+++ b/crates/ra_hir_ty/src/db.rs
@@ -13,7 +13,7 @@ use ra_prof::profile;
13use crate::{ 13use crate::{
14 method_resolution::{InherentImpls, TraitImpls}, 14 method_resolution::{InherentImpls, TraitImpls},
15 traits::chalk, 15 traits::chalk,
16 Binders, CallableDef, GenericPredicate, InferenceResult, OpaqueTyId, PolyFnSig, 16 Binders, CallableDefId, GenericPredicate, InferenceResult, OpaqueTyId, PolyFnSig,
17 ReturnTypeImplTraits, TraitRef, Ty, TyDefId, ValueTyDefId, 17 ReturnTypeImplTraits, TraitRef, Ty, TyDefId, ValueTyDefId,
18}; 18};
19use hir_expand::name::Name; 19use hir_expand::name::Name;
@@ -45,7 +45,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
45 fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Binders<Ty>>>; 45 fn field_types(&self, var: VariantId) -> Arc<ArenaMap<LocalFieldId, Binders<Ty>>>;
46 46
47 #[salsa::invoke(crate::callable_item_sig)] 47 #[salsa::invoke(crate::callable_item_sig)]
48 fn callable_item_signature(&self, def: CallableDef) -> PolyFnSig; 48 fn callable_item_signature(&self, def: CallableDefId) -> PolyFnSig;
49 49
50 #[salsa::invoke(crate::lower::return_type_impl_traits)] 50 #[salsa::invoke(crate::lower::return_type_impl_traits)]
51 fn return_type_impl_traits( 51 fn return_type_impl_traits(
@@ -77,7 +77,7 @@ pub trait HirDatabase: DefDatabase + Upcast<dyn DefDatabase> {
77 77
78 // Interned IDs for Chalk integration 78 // Interned IDs for Chalk integration
79 #[salsa::interned] 79 #[salsa::interned]
80 fn intern_callable_def(&self, callable_def: CallableDef) -> crate::CallableDefId; 80 fn intern_callable_def(&self, callable_def: CallableDefId) -> InternedCallableDefId;
81 #[salsa::interned] 81 #[salsa::interned]
82 fn intern_type_param_id(&self, param_id: TypeParamId) -> GlobalTypeParamId; 82 fn intern_type_param_id(&self, param_id: TypeParamId) -> GlobalTypeParamId;
83 #[salsa::interned] 83 #[salsa::interned]
@@ -151,3 +151,9 @@ impl_intern_key!(InternedOpaqueTyId);
151#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 151#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
152pub struct ClosureId(salsa::InternId); 152pub struct ClosureId(salsa::InternId);
153impl_intern_key!(ClosureId); 153impl_intern_key!(ClosureId);
154
155/// This exists just for Chalk, because Chalk just has a single `FnDefId` where
156/// we have different IDs for struct and enum variant constructors.
157#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
158pub struct InternedCallableDefId(salsa::InternId);
159impl_intern_key!(InternedCallableDefId);
diff --git a/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs b/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs
index 9e4ed9a8b..5cc76bdce 100644
--- a/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs
+++ b/crates/ra_hir_ty/src/diagnostics/unsafe_check.rs
@@ -11,7 +11,7 @@ use hir_def::{
11use hir_expand::diagnostics::DiagnosticSink; 11use hir_expand::diagnostics::DiagnosticSink;
12 12
13use crate::{ 13use crate::{
14 db::HirDatabase, diagnostics::MissingUnsafe, lower::CallableDef, ApplicationTy, 14 db::HirDatabase, diagnostics::MissingUnsafe, lower::CallableDefId, ApplicationTy,
15 InferenceResult, Ty, TypeCtor, 15 InferenceResult, Ty, TypeCtor,
16}; 16};
17 17
@@ -88,7 +88,7 @@ fn walk_unsafe(
88 Expr::Call { callee, .. } => { 88 Expr::Call { callee, .. } => {
89 let ty = &infer[*callee]; 89 let ty = &infer[*callee];
90 if let &Ty::Apply(ApplicationTy { 90 if let &Ty::Apply(ApplicationTy {
91 ctor: TypeCtor::FnDef(CallableDef::FunctionId(func)), 91 ctor: TypeCtor::FnDef(CallableDefId::FunctionId(func)),
92 .. 92 ..
93 }) = ty 93 }) = ty
94 { 94 {
diff --git a/crates/ra_hir_ty/src/display.rs b/crates/ra_hir_ty/src/display.rs
index c860c254c..758d5f5ac 100644
--- a/crates/ra_hir_ty/src/display.rs
+++ b/crates/ra_hir_ty/src/display.rs
@@ -3,7 +3,7 @@
3use std::fmt; 3use std::fmt;
4 4
5use crate::{ 5use crate::{
6 db::HirDatabase, utils::generics, ApplicationTy, CallableDef, FnSig, GenericPredicate, 6 db::HirDatabase, utils::generics, ApplicationTy, CallableDefId, FnSig, GenericPredicate,
7 Obligation, OpaqueTyId, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, 7 Obligation, OpaqueTyId, ProjectionTy, Substs, TraitRef, Ty, TypeCtor,
8}; 8};
9use hir_def::{ 9use hir_def::{
@@ -263,9 +263,11 @@ impl HirDisplay for ApplicationTy {
263 TypeCtor::FnDef(def) => { 263 TypeCtor::FnDef(def) => {
264 let sig = f.db.callable_item_signature(def).subst(&self.parameters); 264 let sig = f.db.callable_item_signature(def).subst(&self.parameters);
265 match def { 265 match def {
266 CallableDef::FunctionId(ff) => write!(f, "fn {}", f.db.function_data(ff).name)?, 266 CallableDefId::FunctionId(ff) => {
267 CallableDef::StructId(s) => write!(f, "{}", f.db.struct_data(s).name)?, 267 write!(f, "fn {}", f.db.function_data(ff).name)?
268 CallableDef::EnumVariantId(e) => { 268 }
269 CallableDefId::StructId(s) => write!(f, "{}", f.db.struct_data(s).name)?,
270 CallableDefId::EnumVariantId(e) => {
269 write!(f, "{}", f.db.enum_data(e.parent).variants[e.local_id].name)? 271 write!(f, "{}", f.db.enum_data(e.parent).variants[e.local_id].name)?
270 } 272 }
271 }; 273 };
diff --git a/crates/ra_hir_ty/src/infer/expr.rs b/crates/ra_hir_ty/src/infer/expr.rs
index ab586b018..731b062c2 100644
--- a/crates/ra_hir_ty/src/infer/expr.rs
+++ b/crates/ra_hir_ty/src/infer/expr.rs
@@ -17,7 +17,7 @@ use crate::{
17 autoderef, method_resolution, op, 17 autoderef, method_resolution, op,
18 traits::{FnTrait, InEnvironment}, 18 traits::{FnTrait, InEnvironment},
19 utils::{generics, variant_data, Generics}, 19 utils::{generics, variant_data, Generics},
20 ApplicationTy, Binders, CallableDef, InferTy, IntTy, Mutability, Obligation, Rawness, Substs, 20 ApplicationTy, Binders, CallableDefId, InferTy, IntTy, Mutability, Obligation, Rawness, Substs,
21 TraitRef, Ty, TypeCtor, 21 TraitRef, Ty, TypeCtor,
22}; 22};
23 23
@@ -854,7 +854,7 @@ impl<'a> InferenceContext<'a> {
854 } 854 }
855 // add obligation for trait implementation, if this is a trait method 855 // add obligation for trait implementation, if this is a trait method
856 match def { 856 match def {
857 CallableDef::FunctionId(f) => { 857 CallableDefId::FunctionId(f) => {
858 if let AssocContainerId::TraitId(trait_) = 858 if let AssocContainerId::TraitId(trait_) =
859 f.lookup(self.db.upcast()).container 859 f.lookup(self.db.upcast()).container
860 { 860 {
@@ -865,7 +865,7 @@ impl<'a> InferenceContext<'a> {
865 self.obligations.push(Obligation::Trait(TraitRef { trait_, substs })); 865 self.obligations.push(Obligation::Trait(TraitRef { trait_, substs }));
866 } 866 }
867 } 867 }
868 CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => {} 868 CallableDefId::StructId(_) | CallableDefId::EnumVariantId(_) => {}
869 } 869 }
870 } 870 }
871 } 871 }
diff --git a/crates/ra_hir_ty/src/lib.rs b/crates/ra_hir_ty/src/lib.rs
index 9f034eca5..0ef5ca78f 100644
--- a/crates/ra_hir_ty/src/lib.rs
+++ b/crates/ra_hir_ty/src/lib.rs
@@ -33,7 +33,7 @@ use hir_def::{
33 TypeParamId, 33 TypeParamId,
34}; 34};
35use itertools::Itertools; 35use itertools::Itertools;
36use ra_db::{impl_intern_key, salsa, CrateId}; 36use ra_db::{salsa, CrateId};
37 37
38use crate::{ 38use crate::{
39 db::HirDatabase, 39 db::HirDatabase,
@@ -44,7 +44,7 @@ use crate::{
44 44
45pub use autoderef::autoderef; 45pub use autoderef::autoderef;
46pub use infer::{InferTy, InferenceResult}; 46pub use infer::{InferTy, InferenceResult};
47pub use lower::CallableDef; 47pub use lower::CallableDefId;
48pub use lower::{ 48pub use lower::{
49 associated_type_shorthand_candidates, callable_item_sig, ImplTraitLoweringMode, TyDefId, 49 associated_type_shorthand_candidates, callable_item_sig, ImplTraitLoweringMode, TyDefId,
50 TyLoweringContext, ValueTyDefId, 50 TyLoweringContext, ValueTyDefId,
@@ -102,7 +102,7 @@ pub enum TypeCtor {
102 /// fn foo() -> i32 { 1 } 102 /// fn foo() -> i32 { 1 }
103 /// let bar = foo; // bar: fn() -> i32 {foo} 103 /// let bar = foo; // bar: fn() -> i32 {foo}
104 /// ``` 104 /// ```
105 FnDef(CallableDef), 105 FnDef(CallableDefId),
106 106
107 /// A pointer to a function. Written as `fn() -> i32`. 107 /// A pointer to a function. Written as `fn() -> i32`.
108 /// 108 ///
@@ -140,12 +140,6 @@ pub enum TypeCtor {
140 Closure { def: DefWithBodyId, expr: ExprId }, 140 Closure { def: DefWithBodyId, expr: ExprId },
141} 141}
142 142
143/// This exists just for Chalk, because Chalk just has a single `FnDefId` where
144/// we have different IDs for struct and enum variant constructors.
145#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Ord, PartialOrd)]
146pub struct CallableDefId(salsa::InternId);
147impl_intern_key!(CallableDefId);
148
149impl TypeCtor { 143impl TypeCtor {
150 pub fn num_ty_params(self, db: &dyn HirDatabase) -> usize { 144 pub fn num_ty_params(self, db: &dyn HirDatabase) -> usize {
151 match self { 145 match self {
@@ -773,7 +767,7 @@ impl Ty {
773 } 767 }
774 } 768 }
775 769
776 pub fn as_callable(&self) -> Option<(CallableDef, &Substs)> { 770 pub fn as_callable(&self) -> Option<(CallableDefId, &Substs)> {
777 match self { 771 match self {
778 Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(callable_def), parameters }) => { 772 Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(callable_def), parameters }) => {
779 Some((*callable_def, parameters)) 773 Some((*callable_def, parameters))
diff --git a/crates/ra_hir_ty/src/lower.rs b/crates/ra_hir_ty/src/lower.rs
index 6f4398e84..f274579ea 100644
--- a/crates/ra_hir_ty/src/lower.rs
+++ b/crates/ra_hir_ty/src/lower.rs
@@ -768,11 +768,11 @@ fn count_impl_traits(type_ref: &TypeRef) -> usize {
768} 768}
769 769
770/// Build the signature of a callable item (function, struct or enum variant). 770/// Build the signature of a callable item (function, struct or enum variant).
771pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDef) -> PolyFnSig { 771pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDefId) -> PolyFnSig {
772 match def { 772 match def {
773 CallableDef::FunctionId(f) => fn_sig_for_fn(db, f), 773 CallableDefId::FunctionId(f) => fn_sig_for_fn(db, f),
774 CallableDef::StructId(s) => fn_sig_for_struct_constructor(db, s), 774 CallableDefId::StructId(s) => fn_sig_for_struct_constructor(db, s),
775 CallableDef::EnumVariantId(e) => fn_sig_for_enum_variant_constructor(db, e), 775 CallableDefId::EnumVariantId(e) => fn_sig_for_enum_variant_constructor(db, e),
776 } 776 }
777} 777}
778 778
@@ -1107,31 +1107,31 @@ fn type_for_type_alias(db: &dyn HirDatabase, t: TypeAliasId) -> Binders<Ty> {
1107} 1107}
1108 1108
1109#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] 1109#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
1110pub enum CallableDef { 1110pub enum CallableDefId {
1111 FunctionId(FunctionId), 1111 FunctionId(FunctionId),
1112 StructId(StructId), 1112 StructId(StructId),
1113 EnumVariantId(EnumVariantId), 1113 EnumVariantId(EnumVariantId),
1114} 1114}
1115impl_from!(FunctionId, StructId, EnumVariantId for CallableDef); 1115impl_from!(FunctionId, StructId, EnumVariantId for CallableDefId);
1116 1116
1117impl CallableDef { 1117impl CallableDefId {
1118 pub fn krate(self, db: &dyn HirDatabase) -> CrateId { 1118 pub fn krate(self, db: &dyn HirDatabase) -> CrateId {
1119 let db = db.upcast(); 1119 let db = db.upcast();
1120 match self { 1120 match self {
1121 CallableDef::FunctionId(f) => f.lookup(db).module(db), 1121 CallableDefId::FunctionId(f) => f.lookup(db).module(db),
1122 CallableDef::StructId(s) => s.lookup(db).container.module(db), 1122 CallableDefId::StructId(s) => s.lookup(db).container.module(db),
1123 CallableDef::EnumVariantId(e) => e.parent.lookup(db).container.module(db), 1123 CallableDefId::EnumVariantId(e) => e.parent.lookup(db).container.module(db),
1124 } 1124 }
1125 .krate 1125 .krate
1126 } 1126 }
1127} 1127}
1128 1128
1129impl From<CallableDef> for GenericDefId { 1129impl From<CallableDefId> for GenericDefId {
1130 fn from(def: CallableDef) -> GenericDefId { 1130 fn from(def: CallableDefId) -> GenericDefId {
1131 match def { 1131 match def {
1132 CallableDef::FunctionId(f) => f.into(), 1132 CallableDefId::FunctionId(f) => f.into(),
1133 CallableDef::StructId(s) => s.into(), 1133 CallableDefId::StructId(s) => s.into(),
1134 CallableDef::EnumVariantId(e) => e.into(), 1134 CallableDefId::EnumVariantId(e) => e.into(),
1135 } 1135 }
1136 } 1136 }
1137} 1137}
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs
index 1ef5baa05..78d0bc43b 100644
--- a/crates/ra_hir_ty/src/traits/chalk.rs
+++ b/crates/ra_hir_ty/src/traits/chalk.rs
@@ -18,7 +18,7 @@ use crate::{
18 display::HirDisplay, 18 display::HirDisplay,
19 method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS}, 19 method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS},
20 utils::generics, 20 utils::generics,
21 CallableDef, DebruijnIndex, FnSig, GenericPredicate, Substs, Ty, TypeCtor, 21 CallableDefId, DebruijnIndex, FnSig, GenericPredicate, Substs, Ty, TypeCtor,
22}; 22};
23use mapping::{ 23use mapping::{
24 convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue, 24 convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsValue,
@@ -525,7 +525,7 @@ pub(crate) fn fn_def_datum_query(
525 _krate: CrateId, 525 _krate: CrateId,
526 fn_def_id: FnDefId, 526 fn_def_id: FnDefId,
527) -> Arc<FnDefDatum> { 527) -> Arc<FnDefDatum> {
528 let callable_def: CallableDef = from_chalk(db, fn_def_id); 528 let callable_def: CallableDefId = from_chalk(db, fn_def_id);
529 let generic_params = generics(db.upcast(), callable_def.into()); 529 let generic_params = generics(db.upcast(), callable_def.into());
530 let sig = db.callable_item_signature(callable_def); 530 let sig = db.callable_item_signature(callable_def);
531 let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST); 531 let bound_vars = Substs::bound_vars(&generic_params, DebruijnIndex::INNERMOST);
@@ -552,14 +552,14 @@ pub(crate) fn fn_def_datum_query(
552 Arc::new(datum) 552 Arc::new(datum)
553} 553}
554 554
555impl From<FnDefId> for crate::CallableDefId { 555impl From<FnDefId> for crate::db::InternedCallableDefId {
556 fn from(fn_def_id: FnDefId) -> Self { 556 fn from(fn_def_id: FnDefId) -> Self {
557 InternKey::from_intern_id(fn_def_id.0) 557 InternKey::from_intern_id(fn_def_id.0)
558 } 558 }
559} 559}
560 560
561impl From<crate::CallableDefId> for FnDefId { 561impl From<crate::db::InternedCallableDefId> for FnDefId {
562 fn from(callable_def_id: crate::CallableDefId) -> Self { 562 fn from(callable_def_id: crate::db::InternedCallableDefId) -> Self {
563 chalk_ir::FnDefId(callable_def_id.as_intern_id()) 563 chalk_ir::FnDefId(callable_def_id.as_intern_id())
564 } 564 }
565} 565}
diff --git a/crates/ra_hir_ty/src/traits/chalk/mapping.rs b/crates/ra_hir_ty/src/traits/chalk/mapping.rs
index a852ce2ac..09d8347ca 100644
--- a/crates/ra_hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/mapping.rs
@@ -16,7 +16,7 @@ use crate::{
16 db::HirDatabase, 16 db::HirDatabase,
17 primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness}, 17 primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness},
18 traits::{Canonical, Obligation}, 18 traits::{Canonical, Obligation},
19 ApplicationTy, CallableDef, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, 19 ApplicationTy, CallableDefId, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId,
20 ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TyKind, TypeCtor, 20 ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TyKind, TypeCtor,
21}; 21};
22 22
@@ -454,14 +454,14 @@ impl ToChalk for hir_def::ImplId {
454 } 454 }
455} 455}
456 456
457impl ToChalk for CallableDef { 457impl ToChalk for CallableDefId {
458 type Chalk = FnDefId; 458 type Chalk = FnDefId;
459 459
460 fn to_chalk(self, db: &dyn HirDatabase) -> FnDefId { 460 fn to_chalk(self, db: &dyn HirDatabase) -> FnDefId {
461 db.intern_callable_def(self).into() 461 db.intern_callable_def(self).into()
462 } 462 }
463 463
464 fn from_chalk(db: &dyn HirDatabase, fn_def_id: FnDefId) -> CallableDef { 464 fn from_chalk(db: &dyn HirDatabase, fn_def_id: FnDefId) -> CallableDefId {
465 db.lookup_intern_callable_def(fn_def_id.into()) 465 db.lookup_intern_callable_def(fn_def_id.into())
466 } 466 }
467} 467}
diff --git a/crates/ra_hir_ty/src/traits/chalk/tls.rs b/crates/ra_hir_ty/src/traits/chalk/tls.rs
index 1e226baea..db915625c 100644
--- a/crates/ra_hir_ty/src/traits/chalk/tls.rs
+++ b/crates/ra_hir_ty/src/traits/chalk/tls.rs
@@ -5,7 +5,7 @@ use chalk_ir::{AliasTy, GenericArg, Goal, Goals, Lifetime, ProgramClauseImplicat
5use itertools::Itertools; 5use itertools::Itertools;
6 6
7use super::{from_chalk, Interner}; 7use super::{from_chalk, Interner};
8use crate::{db::HirDatabase, CallableDef, TypeCtor}; 8use crate::{db::HirDatabase, CallableDefId, TypeCtor};
9use hir_def::{AdtId, AssocContainerId, DefWithBodyId, Lookup, TypeAliasId}; 9use hir_def::{AdtId, AssocContainerId, DefWithBodyId, Lookup, TypeAliasId};
10 10
11pub use unsafe_tls::{set_current_program, with_current_program}; 11pub use unsafe_tls::{set_current_program, with_current_program};
@@ -38,16 +38,16 @@ impl DebugContext<'_> {
38 } 38 }
39 TypeCtor::FnDef(def) => { 39 TypeCtor::FnDef(def) => {
40 let name = match def { 40 let name = match def {
41 CallableDef::FunctionId(ff) => self.0.function_data(ff).name.clone(), 41 CallableDefId::FunctionId(ff) => self.0.function_data(ff).name.clone(),
42 CallableDef::StructId(s) => self.0.struct_data(s).name.clone(), 42 CallableDefId::StructId(s) => self.0.struct_data(s).name.clone(),
43 CallableDef::EnumVariantId(e) => { 43 CallableDefId::EnumVariantId(e) => {
44 let enum_data = self.0.enum_data(e.parent); 44 let enum_data = self.0.enum_data(e.parent);
45 enum_data.variants[e.local_id].name.clone() 45 enum_data.variants[e.local_id].name.clone()
46 } 46 }
47 }; 47 };
48 match def { 48 match def {
49 CallableDef::FunctionId(_) => write!(f, "{{fn {}}}", name)?, 49 CallableDefId::FunctionId(_) => write!(f, "{{fn {}}}", name)?,
50 CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => { 50 CallableDefId::StructId(_) | CallableDefId::EnumVariantId(_) => {
51 write!(f, "{{ctor {}}}", name)? 51 write!(f, "{{ctor {}}}", name)?
52 } 52 }
53 } 53 }
@@ -255,18 +255,18 @@ impl DebugContext<'_> {
255 fn_def_id: chalk_ir::FnDefId<Interner>, 255 fn_def_id: chalk_ir::FnDefId<Interner>,
256 fmt: &mut fmt::Formatter<'_>, 256 fmt: &mut fmt::Formatter<'_>,
257 ) -> Result<(), fmt::Error> { 257 ) -> Result<(), fmt::Error> {
258 let def: CallableDef = from_chalk(self.0, fn_def_id); 258 let def: CallableDefId = from_chalk(self.0, fn_def_id);
259 let name = match def { 259 let name = match def {
260 CallableDef::FunctionId(ff) => self.0.function_data(ff).name.clone(), 260 CallableDefId::FunctionId(ff) => self.0.function_data(ff).name.clone(),
261 CallableDef::StructId(s) => self.0.struct_data(s).name.clone(), 261 CallableDefId::StructId(s) => self.0.struct_data(s).name.clone(),
262 CallableDef::EnumVariantId(e) => { 262 CallableDefId::EnumVariantId(e) => {
263 let enum_data = self.0.enum_data(e.parent); 263 let enum_data = self.0.enum_data(e.parent);
264 enum_data.variants[e.local_id].name.clone() 264 enum_data.variants[e.local_id].name.clone()
265 } 265 }
266 }; 266 };
267 match def { 267 match def {
268 CallableDef::FunctionId(_) => write!(fmt, "{{fn {}}}", name), 268 CallableDefId::FunctionId(_) => write!(fmt, "{{fn {}}}", name),
269 CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => { 269 CallableDefId::StructId(_) | CallableDefId::EnumVariantId(_) => {
270 write!(fmt, "{{ctor {}}}", name) 270 write!(fmt, "{{ctor {}}}", name)
271 } 271 }
272 } 272 }
diff --git a/crates/ra_ide/src/call_hierarchy.rs b/crates/ra_ide/src/call_hierarchy.rs
index 884353808..cb7e62cd6 100644
--- a/crates/ra_ide/src/call_hierarchy.rs
+++ b/crates/ra_ide/src/call_hierarchy.rs
@@ -97,7 +97,7 @@ pub(crate) fn outgoing_calls(db: &RootDatabase, position: FilePosition) -> Optio
97 //FIXME: Type::as_callable is broken 97 //FIXME: Type::as_callable is broken
98 let callable_def = sema.type_of_expr(&expr.expr()?)?.as_callable()?; 98 let callable_def = sema.type_of_expr(&expr.expr()?)?.as_callable()?;
99 match callable_def { 99 match callable_def {
100 hir::CallableDef::FunctionId(it) => { 100 hir::CallableDefId::FunctionId(it) => {
101 let fn_def: hir::Function = it.into(); 101 let fn_def: hir::Function = it.into();
102 let nav = fn_def.to_nav(db); 102 let nav = fn_def.to_nav(db);
103 Some(nav) 103 Some(nav)
diff --git a/crates/ra_ide/src/call_info.rs b/crates/ra_ide/src/call_info.rs
index 0ef92ed4b..1fe1c21de 100644
--- a/crates/ra_ide/src/call_info.rs
+++ b/crates/ra_ide/src/call_info.rs
@@ -53,14 +53,14 @@ fn call_info_for_token(sema: &Semantics<RootDatabase>, token: SyntaxToken) -> Op
53 //FIXME: Type::as_callable is broken 53 //FIXME: Type::as_callable is broken
54 let callable_def = sema.type_of_expr(&call.expr()?)?.as_callable()?; 54 let callable_def = sema.type_of_expr(&call.expr()?)?.as_callable()?;
55 match callable_def { 55 match callable_def {
56 hir::CallableDef::FunctionId(it) => { 56 hir::CallableDefId::FunctionId(it) => {
57 let fn_def = it.into(); 57 let fn_def = it.into();
58 FunctionSignature::from_hir(sema.db, fn_def) 58 FunctionSignature::from_hir(sema.db, fn_def)
59 } 59 }
60 hir::CallableDef::StructId(it) => { 60 hir::CallableDefId::StructId(it) => {
61 FunctionSignature::from_struct(sema.db, it.into())? 61 FunctionSignature::from_struct(sema.db, it.into())?
62 } 62 }
63 hir::CallableDef::EnumVariantId(it) => { 63 hir::CallableDefId::EnumVariantId(it) => {
64 FunctionSignature::from_enum_variant(sema.db, it.into())? 64 FunctionSignature::from_enum_variant(sema.db, it.into())?
65 } 65 }
66 } 66 }
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs
index 35ab741d8..3cbae8a45 100644
--- a/crates/ra_ide/src/inlay_hints.rs
+++ b/crates/ra_ide/src/inlay_hints.rs
@@ -324,13 +324,13 @@ fn get_fn_signature(sema: &Semantics<RootDatabase>, expr: &ast::Expr) -> Option<
324 // FIXME: Type::as_callable is broken for closures 324 // FIXME: Type::as_callable is broken for closures
325 let callable_def = sema.type_of_expr(&expr.expr()?)?.as_callable()?; 325 let callable_def = sema.type_of_expr(&expr.expr()?)?.as_callable()?;
326 match callable_def { 326 match callable_def {
327 hir::CallableDef::FunctionId(it) => { 327 hir::CallableDefId::FunctionId(it) => {
328 Some(FunctionSignature::from_hir(sema.db, it.into())) 328 Some(FunctionSignature::from_hir(sema.db, it.into()))
329 } 329 }
330 hir::CallableDef::StructId(it) => { 330 hir::CallableDefId::StructId(it) => {
331 FunctionSignature::from_struct(sema.db, it.into()) 331 FunctionSignature::from_struct(sema.db, it.into())
332 } 332 }
333 hir::CallableDef::EnumVariantId(it) => { 333 hir::CallableDefId::EnumVariantId(it) => {
334 FunctionSignature::from_enum_variant(sema.db, it.into()) 334 FunctionSignature::from_enum_variant(sema.db, it.into())
335 } 335 }
336 } 336 }