diff options
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 4 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 38 |
2 files changed, 7 insertions, 35 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index 565672b6b..4e7d43f7e 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -33,13 +33,13 @@ pub(super) mod tls; | |||
33 | mod interner; | 33 | mod interner; |
34 | mod mapping; | 34 | mod mapping; |
35 | 35 | ||
36 | pub(super) trait ToChalk { | 36 | pub(crate) trait ToChalk { |
37 | type Chalk; | 37 | type Chalk; |
38 | fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk; | 38 | fn to_chalk(self, db: &dyn HirDatabase) -> Self::Chalk; |
39 | fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self; | 39 | fn from_chalk(db: &dyn HirDatabase, chalk: Self::Chalk) -> Self; |
40 | } | 40 | } |
41 | 41 | ||
42 | pub(super) fn from_chalk<T, ChalkT>(db: &dyn HirDatabase, chalk: ChalkT) -> T | 42 | pub(crate) fn from_chalk<T, ChalkT>(db: &dyn HirDatabase, chalk: ChalkT) -> T |
43 | where | 43 | where |
44 | T: ToChalk<Chalk = ChalkT>, | 44 | T: ToChalk<Chalk = ChalkT>, |
45 | { | 45 | { |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 3a08b67e9..b0415e8b0 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -17,7 +17,7 @@ use crate::{ | |||
17 | primitive::UintTy, | 17 | primitive::UintTy, |
18 | traits::{Canonical, Obligation}, | 18 | traits::{Canonical, Obligation}, |
19 | AliasTy, CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy, | 19 | AliasTy, CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy, |
20 | OpaqueTyId, ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment, TraitRef, Ty, | 20 | OpaqueTyId, ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | use super::interner::*; | 23 | use super::interner::*; |
@@ -536,31 +536,6 @@ where | |||
536 | } | 536 | } |
537 | } | 537 | } |
538 | 538 | ||
539 | impl ToChalk for Arc<TraitEnvironment> { | ||
540 | type Chalk = chalk_ir::Environment<Interner>; | ||
541 | |||
542 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Environment<Interner> { | ||
543 | let mut clauses = Vec::new(); | ||
544 | for pred in &self.predicates { | ||
545 | if pred.is_error() { | ||
546 | // for env, we just ignore errors | ||
547 | continue; | ||
548 | } | ||
549 | let program_clause: chalk_ir::ProgramClause<Interner> = | ||
550 | pred.clone().to_chalk(db).cast(&Interner); | ||
551 | clauses.push(program_clause.into_from_env_clause(&Interner)); | ||
552 | } | ||
553 | chalk_ir::Environment::new(&Interner).add_clauses(&Interner, clauses) | ||
554 | } | ||
555 | |||
556 | fn from_chalk( | ||
557 | _db: &dyn HirDatabase, | ||
558 | _env: chalk_ir::Environment<Interner>, | ||
559 | ) -> Arc<TraitEnvironment> { | ||
560 | unimplemented!() | ||
561 | } | ||
562 | } | ||
563 | |||
564 | impl<T: ToChalk> ToChalk for InEnvironment<T> | 539 | impl<T: ToChalk> ToChalk for InEnvironment<T> |
565 | where | 540 | where |
566 | T::Chalk: chalk_ir::interner::HasInterner<Interner = Interner>, | 541 | T::Chalk: chalk_ir::interner::HasInterner<Interner = Interner>, |
@@ -569,19 +544,16 @@ where | |||
569 | 544 | ||
570 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> { | 545 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::InEnvironment<T::Chalk> { |
571 | chalk_ir::InEnvironment { | 546 | chalk_ir::InEnvironment { |
572 | environment: self.environment.to_chalk(db), | 547 | environment: self.environment.env.clone(), |
573 | goal: self.value.to_chalk(db), | 548 | goal: self.value.to_chalk(db), |
574 | } | 549 | } |
575 | } | 550 | } |
576 | 551 | ||
577 | fn from_chalk( | 552 | fn from_chalk( |
578 | db: &dyn HirDatabase, | 553 | _db: &dyn HirDatabase, |
579 | in_env: chalk_ir::InEnvironment<T::Chalk>, | 554 | _in_env: chalk_ir::InEnvironment<T::Chalk>, |
580 | ) -> InEnvironment<T> { | 555 | ) -> InEnvironment<T> { |
581 | InEnvironment { | 556 | unimplemented!() |
582 | environment: from_chalk(db, in_env.environment), | ||
583 | value: from_chalk(db, in_env.goal), | ||
584 | } | ||
585 | } | 557 | } |
586 | } | 558 | } |
587 | 559 | ||