From 5ca481bbdc75bd3a9dbce4c94b014bd0eb8bd9e8 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 9 Apr 2021 14:15:26 +0200 Subject: Move ToChalk -> mapping --- crates/hir_ty/src/chalk_db.rs | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) (limited to 'crates/hir_ty/src/chalk_db.rs') diff --git a/crates/hir_ty/src/chalk_db.rs b/crates/hir_ty/src/chalk_db.rs index 566e4f406..f5b2c5ff0 100644 --- a/crates/hir_ty/src/chalk_db.rs +++ b/crates/hir_ty/src/chalk_db.rs @@ -1,4 +1,5 @@ -//! Conversion code from/to Chalk. +//! The implementation of `RustIrDatabase` for Chalk, which provides information +//! about the code that Chalk needs. use std::sync::Arc; use log::debug; @@ -13,7 +14,21 @@ use hir_def::{ }; use hir_expand::name::name; -use crate::{AliasEq, AliasTy, BoundVar, CallableDefId, DebruijnIndex, FnDefId, Interner, ProjectionTy, Substitution, TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, WhereClause, traits::ChalkContext, db::HirDatabase, display::HirDisplay, from_assoc_type_id, make_only_type_binders, mapping::{convert_where_clauses, generic_predicate_to_inline_bound, TypeAliasAsValue}, method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS}, to_assoc_type_id, to_chalk_trait_id, utils::generics}; +use crate::{ + db::HirDatabase, + display::HirDisplay, + from_assoc_type_id, make_only_type_binders, + mapping::{ + convert_where_clauses, from_chalk, generic_predicate_to_inline_bound, ToChalk, + TypeAliasAsValue, + }, + method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS}, + to_assoc_type_id, to_chalk_trait_id, + traits::ChalkContext, + utils::generics, + AliasEq, AliasTy, BoundVar, CallableDefId, DebruijnIndex, FnDefId, Interner, ProjectionTy, + Substitution, TraitRef, TraitRefExt, Ty, TyBuilder, TyExt, TyKind, WhereClause, +}; pub(crate) type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum; pub(crate) type TraitDatum = chalk_solve::rust_ir::TraitDatum; @@ -31,19 +46,6 @@ pub(crate) type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue; pub(crate) type Variances = chalk_ir::Variances; -pub(crate) trait ToChalk { - type Chalk; - fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk; - fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self; -} - -pub(crate) fn from_chalk(db: &dyn HirDatabase, chalk: ChalkT) -> T -where - T: ToChalk, -{ - T::from_chalk(db, chalk) -} - impl<'a> chalk_solve::RustIrDatabase for ChalkContext<'a> { fn associated_ty_data(&self, id: AssocTypeId) -> Arc { self.db.associated_ty_data(id) -- cgit v1.2.3