aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/lib.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-04-09 13:28:04 +0100
committerFlorian Diebold <[email protected]>2021-04-09 13:28:04 +0100
commit2f02977e56a44a5f78576a25547672cd8f910f13 (patch)
tree33e5c6bece12b76d2506bf56783d089040283ad1 /crates/hir_ty/src/lib.rs
parent9fba7cf827cf332800053eb26f10d67efeee7886 (diff)
More moving stuff around
Diffstat (limited to 'crates/hir_ty/src/lib.rs')
-rw-r--r--crates/hir_ty/src/lib.rs61
1 files changed, 6 insertions, 55 deletions
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 434e2e533..6b5006f5d 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -34,16 +34,12 @@ mod test_db;
34 34
35use std::sync::Arc; 35use std::sync::Arc;
36 36
37use base_db::salsa;
38use chalk_ir::{ 37use chalk_ir::{
39 fold::{Fold, Shift}, 38 fold::{Fold, Shift},
40 interner::HasInterner, 39 interner::HasInterner,
41 UintTy, 40 UintTy,
42}; 41};
43use hir_def::{ 42use hir_def::{expr::ExprId, type_ref::Rawness, TypeParamId};
44 expr::ExprId, type_ref::Rawness, ConstParamId, LifetimeParamId, TraitId, TypeAliasId,
45 TypeParamId,
46};
47 43
48use crate::{db::HirDatabase, display::HirDisplay, utils::generics}; 44use crate::{db::HirDatabase, display::HirDisplay, utils::generics};
49 45
@@ -56,6 +52,11 @@ pub use lower::{
56 associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode, 52 associated_type_shorthand_candidates, callable_item_sig, CallableDefId, ImplTraitLoweringMode,
57 TyDefId, TyLoweringContext, ValueTyDefId, 53 TyDefId, TyLoweringContext, ValueTyDefId,
58}; 54};
55pub use mapping::{
56 const_from_placeholder_idx, from_assoc_type_id, from_chalk_trait_id, from_foreign_def_id,
57 from_placeholder_idx, lt_from_placeholder_idx, to_assoc_type_id, to_chalk_trait_id,
58 to_foreign_def_id, to_placeholder_idx,
59};
59pub use traits::TraitEnvironment; 60pub use traits::TraitEnvironment;
60pub use walk::TypeWalk; 61pub use walk::TypeWalk;
61 62
@@ -242,56 +243,6 @@ pub(crate) struct ReturnTypeImplTrait {
242 pub(crate) bounds: Binders<Vec<QuantifiedWhereClause>>, 243 pub(crate) bounds: Binders<Vec<QuantifiedWhereClause>>,
243} 244}
244 245
245pub fn to_foreign_def_id(id: TypeAliasId) -> ForeignDefId {
246 chalk_ir::ForeignDefId(salsa::InternKey::as_intern_id(&id))
247}
248
249pub fn from_foreign_def_id(id: ForeignDefId) -> TypeAliasId {
250 salsa::InternKey::from_intern_id(id.0)
251}
252
253pub fn to_assoc_type_id(id: TypeAliasId) -> AssocTypeId {
254 chalk_ir::AssocTypeId(salsa::InternKey::as_intern_id(&id))
255}
256
257pub fn from_assoc_type_id(id: AssocTypeId) -> TypeAliasId {
258 salsa::InternKey::from_intern_id(id.0)
259}
260
261pub fn from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> TypeParamId {
262 assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
263 let interned_id = salsa::InternKey::from_intern_id(salsa::InternId::from(idx.idx));
264 db.lookup_intern_type_param_id(interned_id)
265}
266
267pub fn to_placeholder_idx(db: &dyn HirDatabase, id: TypeParamId) -> PlaceholderIndex {
268 let interned_id = db.intern_type_param_id(id);
269 PlaceholderIndex {
270 ui: chalk_ir::UniverseIndex::ROOT,
271 idx: salsa::InternKey::as_intern_id(&interned_id).as_usize(),
272 }
273}
274
275pub fn lt_from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> LifetimeParamId {
276 assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
277 let interned_id = salsa::InternKey::from_intern_id(salsa::InternId::from(idx.idx));
278 db.lookup_intern_lifetime_param_id(interned_id)
279}
280
281pub fn const_from_placeholder_idx(db: &dyn HirDatabase, idx: PlaceholderIndex) -> ConstParamId {
282 assert_eq!(idx.ui, chalk_ir::UniverseIndex::ROOT);
283 let interned_id = salsa::InternKey::from_intern_id(salsa::InternId::from(idx.idx));
284 db.lookup_intern_const_param_id(interned_id)
285}
286
287pub fn to_chalk_trait_id(id: TraitId) -> ChalkTraitId {
288 chalk_ir::TraitId(salsa::InternKey::as_intern_id(&id))
289}
290
291pub fn from_chalk_trait_id(id: ChalkTraitId) -> TraitId {
292 salsa::InternKey::from_intern_id(id.0)
293}
294
295pub fn static_lifetime() -> Lifetime { 246pub fn static_lifetime() -> Lifetime {
296 LifetimeData::Static.intern(&Interner) 247 LifetimeData::Static.intern(&Interner)
297} 248}