From b5ce84b17023d27f4e96ec7911aca712db0e000b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 16 Jul 2020 13:15:00 +0200 Subject: Align CallableDefId naming with other ids --- crates/ra_hir_ty/src/traits/chalk/mapping.rs | 6 +++--- crates/ra_hir_ty/src/traits/chalk/tls.rs | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) (limited to 'crates/ra_hir_ty/src/traits/chalk') 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::{ db::HirDatabase, primitive::{FloatBitness, FloatTy, IntBitness, IntTy, Signedness}, traits::{Canonical, Obligation}, - ApplicationTy, CallableDef, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, + ApplicationTy, CallableDefId, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, ProjectionPredicate, ProjectionTy, Substs, TraitEnvironment, TraitRef, Ty, TyKind, TypeCtor, }; @@ -454,14 +454,14 @@ impl ToChalk for hir_def::ImplId { } } -impl ToChalk for CallableDef { +impl ToChalk for CallableDefId { type Chalk = FnDefId; fn to_chalk(self, db: &dyn HirDatabase) -> FnDefId { db.intern_callable_def(self).into() } - fn from_chalk(db: &dyn HirDatabase, fn_def_id: FnDefId) -> CallableDef { + fn from_chalk(db: &dyn HirDatabase, fn_def_id: FnDefId) -> CallableDefId { db.lookup_intern_callable_def(fn_def_id.into()) } } 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 use itertools::Itertools; use super::{from_chalk, Interner}; -use crate::{db::HirDatabase, CallableDef, TypeCtor}; +use crate::{db::HirDatabase, CallableDefId, TypeCtor}; use hir_def::{AdtId, AssocContainerId, DefWithBodyId, Lookup, TypeAliasId}; pub use unsafe_tls::{set_current_program, with_current_program}; @@ -38,16 +38,16 @@ impl DebugContext<'_> { } TypeCtor::FnDef(def) => { let name = match def { - CallableDef::FunctionId(ff) => self.0.function_data(ff).name.clone(), - CallableDef::StructId(s) => self.0.struct_data(s).name.clone(), - CallableDef::EnumVariantId(e) => { + CallableDefId::FunctionId(ff) => self.0.function_data(ff).name.clone(), + CallableDefId::StructId(s) => self.0.struct_data(s).name.clone(), + CallableDefId::EnumVariantId(e) => { let enum_data = self.0.enum_data(e.parent); enum_data.variants[e.local_id].name.clone() } }; match def { - CallableDef::FunctionId(_) => write!(f, "{{fn {}}}", name)?, - CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => { + CallableDefId::FunctionId(_) => write!(f, "{{fn {}}}", name)?, + CallableDefId::StructId(_) | CallableDefId::EnumVariantId(_) => { write!(f, "{{ctor {}}}", name)? } } @@ -255,18 +255,18 @@ impl DebugContext<'_> { fn_def_id: chalk_ir::FnDefId, fmt: &mut fmt::Formatter<'_>, ) -> Result<(), fmt::Error> { - let def: CallableDef = from_chalk(self.0, fn_def_id); + let def: CallableDefId = from_chalk(self.0, fn_def_id); let name = match def { - CallableDef::FunctionId(ff) => self.0.function_data(ff).name.clone(), - CallableDef::StructId(s) => self.0.struct_data(s).name.clone(), - CallableDef::EnumVariantId(e) => { + CallableDefId::FunctionId(ff) => self.0.function_data(ff).name.clone(), + CallableDefId::StructId(s) => self.0.struct_data(s).name.clone(), + CallableDefId::EnumVariantId(e) => { let enum_data = self.0.enum_data(e.parent); enum_data.variants[e.local_id].name.clone() } }; match def { - CallableDef::FunctionId(_) => write!(fmt, "{{fn {}}}", name), - CallableDef::StructId(_) | CallableDef::EnumVariantId(_) => { + CallableDefId::FunctionId(_) => write!(fmt, "{{fn {}}}", name), + CallableDefId::StructId(_) | CallableDefId::EnumVariantId(_) => { write!(fmt, "{{ctor {}}}", name) } } -- cgit v1.2.3