diff options
Diffstat (limited to 'crates/ra_hir_ty/src')
-rw-r--r-- | crates/ra_hir_ty/src/db.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/diagnostics/unsafe_check.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/display.rs | 10 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/infer/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lib.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/lower.rs | 30 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/mapping.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk/tls.rs | 24 |
9 files changed, 49 insertions, 47 deletions
diff --git a/crates/ra_hir_ty/src/db.rs b/crates/ra_hir_ty/src/db.rs index cad3856c9..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; | |||
13 | use crate::{ | 13 | use 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 | }; |
19 | use hir_expand::name::Name; | 19 | use 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) -> InternedCallableDefId; | 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] |
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::{ | |||
11 | use hir_expand::diagnostics::DiagnosticSink; | 11 | use hir_expand::diagnostics::DiagnosticSink; |
12 | 12 | ||
13 | use crate::{ | 13 | use 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 @@ | |||
3 | use std::fmt; | 3 | use std::fmt; |
4 | 4 | ||
5 | use crate::{ | 5 | use 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 | }; |
9 | use hir_def::{ | 9 | use 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 72b089604..0ef5ca78f 100644 --- a/crates/ra_hir_ty/src/lib.rs +++ b/crates/ra_hir_ty/src/lib.rs | |||
@@ -44,7 +44,7 @@ use crate::{ | |||
44 | 44 | ||
45 | pub use autoderef::autoderef; | 45 | pub use autoderef::autoderef; |
46 | pub use infer::{InferTy, InferenceResult}; | 46 | pub use infer::{InferTy, InferenceResult}; |
47 | pub use lower::CallableDef; | 47 | pub use lower::CallableDefId; |
48 | pub use lower::{ | 48 | pub 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 | /// |
@@ -767,7 +767,7 @@ impl Ty { | |||
767 | } | 767 | } |
768 | } | 768 | } |
769 | 769 | ||
770 | pub fn as_callable(&self) -> Option<(CallableDef, &Substs)> { | 770 | pub fn as_callable(&self) -> Option<(CallableDefId, &Substs)> { |
771 | match self { | 771 | match self { |
772 | Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(callable_def), parameters }) => { | 772 | Ty::Apply(ApplicationTy { ctor: TypeCtor::FnDef(callable_def), parameters }) => { |
773 | 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). |
771 | pub fn callable_item_sig(db: &dyn HirDatabase, def: CallableDef) -> PolyFnSig { | 771 | pub 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)] |
1110 | pub enum CallableDef { | 1110 | pub enum CallableDefId { |
1111 | FunctionId(FunctionId), | 1111 | FunctionId(FunctionId), |
1112 | StructId(StructId), | 1112 | StructId(StructId), |
1113 | EnumVariantId(EnumVariantId), | 1113 | EnumVariantId(EnumVariantId), |
1114 | } | 1114 | } |
1115 | impl_from!(FunctionId, StructId, EnumVariantId for CallableDef); | 1115 | impl_from!(FunctionId, StructId, EnumVariantId for CallableDefId); |
1116 | 1116 | ||
1117 | impl CallableDef { | 1117 | impl 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 | ||
1129 | impl From<CallableDef> for GenericDefId { | 1129 | impl 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 e0a6cfe88..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 | }; |
23 | use mapping::{ | 23 | use 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); |
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 | ||
457 | impl ToChalk for CallableDef { | 457 | impl 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 | |||
5 | use itertools::Itertools; | 5 | use itertools::Itertools; |
6 | 6 | ||
7 | use super::{from_chalk, Interner}; | 7 | use super::{from_chalk, Interner}; |
8 | use crate::{db::HirDatabase, CallableDef, TypeCtor}; | 8 | use crate::{db::HirDatabase, CallableDefId, TypeCtor}; |
9 | use hir_def::{AdtId, AssocContainerId, DefWithBodyId, Lookup, TypeAliasId}; | 9 | use hir_def::{AdtId, AssocContainerId, DefWithBodyId, Lookup, TypeAliasId}; |
10 | 10 | ||
11 | pub use unsafe_tls::{set_current_program, with_current_program}; | 11 | pub 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 | } |