From c2a16632d0773dec707acb215297ef55b5c880fe Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Mon, 25 Nov 2019 15:39:12 +0300 Subject: Use GenericDefId more --- crates/ra_hir/src/ty/lower.rs | 16 ++++++++-------- crates/ra_hir/src/ty/traits/chalk.rs | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'crates/ra_hir/src/ty') diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs index b76929501..da3c8e94a 100644 --- a/crates/ra_hir/src/ty/lower.rs +++ b/crates/ra_hir/src/ty/lower.rs @@ -14,7 +14,7 @@ use hir_def::{ path::{GenericArg, PathSegment}, resolver::{HasResolver, Resolver, TypeNs}, type_ref::{TypeBound, TypeRef}, - AdtId, GenericDefId, LocalStructFieldId, VariantId, + AdtId, EnumVariantId, GenericDefId, LocalStructFieldId, VariantId, }; use ra_arena::map::ArenaMap; @@ -605,9 +605,9 @@ impl TraitEnvironment { /// Resolve the where clause(s) of an item with generics. pub(crate) fn generic_predicates_query( db: &impl HirDatabase, - def: GenericDef, + def: GenericDefId, ) -> Arc<[GenericPredicate]> { - let resolver = GenericDefId::from(def).resolver(db); + let resolver = def.resolver(db); resolver .where_predicates_in_scope() .flat_map(|pred| GenericPredicate::from_where_predicate(db, &resolver, pred)) @@ -819,12 +819,12 @@ impl CallableDef { } } -impl From for GenericDef { - fn from(def: CallableDef) -> GenericDef { +impl From for GenericDefId { + fn from(def: CallableDef) -> GenericDefId { match def { - CallableDef::Function(f) => f.into(), - CallableDef::Struct(s) => s.into(), - CallableDef::EnumVariant(e) => e.into(), + CallableDef::Function(f) => f.id.into(), + CallableDef::Struct(s) => s.id.into(), + CallableDef::EnumVariant(e) => EnumVariantId::from(e).into(), } } } diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 1a93e5e50..a0dbf6305 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs @@ -9,7 +9,7 @@ use chalk_ir::{ }; use chalk_rust_ir::{AssociatedTyDatum, AssociatedTyValue, ImplDatum, StructDatum, TraitDatum}; -use hir_def::lang_item::LangItemTarget; +use hir_def::{lang_item::LangItemTarget, GenericDefId}; use hir_expand::name; use ra_db::salsa::{InternId, InternKey}; @@ -19,7 +19,7 @@ use crate::{ db::HirDatabase, ty::display::HirDisplay, ty::{ApplicationTy, GenericPredicate, ProjectionTy, Substs, TraitRef, Ty, TypeCtor, TypeWalk}, - Crate, GenericDef, ImplBlock, Trait, TypeAlias, + Crate, ImplBlock, Trait, TypeAlias, }; /// This represents a trait whose name we could not resolve. @@ -402,7 +402,7 @@ fn make_binders(value: T, num_vars: usize) -> chalk_ir::Binders { fn convert_where_clauses( db: &impl HirDatabase, - def: GenericDef, + def: GenericDefId, substs: &Substs, ) -> Vec> { let generic_predicates = db.generic_predicates(def); @@ -561,7 +561,7 @@ pub(crate) fn trait_datum_query( marker: false, fundamental: false, }; - let where_clauses = convert_where_clauses(db, trait_.into(), &bound_vars); + let where_clauses = convert_where_clauses(db, trait_.id.into(), &bound_vars); let associated_ty_ids = trait_ .items(db) .into_iter() @@ -643,7 +643,7 @@ fn impl_block_datum( } else { chalk_rust_ir::ImplType::External }; - let where_clauses = convert_where_clauses(db, impl_block.into(), &bound_vars); + let where_clauses = convert_where_clauses(db, impl_block.id.into(), &bound_vars); let negative = impl_block.is_negative(db); debug!( "impl {:?}: {}{} where {:?}", -- cgit v1.2.3