diff options
Diffstat (limited to 'crates/hir_ty/src/chalk_cast.rs')
-rw-r--r-- | crates/hir_ty/src/chalk_cast.rs | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/crates/hir_ty/src/chalk_cast.rs b/crates/hir_ty/src/chalk_cast.rs index bf884ae15..df6492113 100644 --- a/crates/hir_ty/src/chalk_cast.rs +++ b/crates/hir_ty/src/chalk_cast.rs | |||
@@ -5,7 +5,7 @@ use chalk_ir::{ | |||
5 | interner::HasInterner, | 5 | interner::HasInterner, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::{AliasEq, DomainGoal, Interner, TraitRef, WhereClause}; | 8 | use crate::{AliasEq, DomainGoal, GenericArg, GenericArgData, Interner, TraitRef, Ty, WhereClause}; |
9 | 9 | ||
10 | macro_rules! has_interner { | 10 | macro_rules! has_interner { |
11 | ($t:ty) => { | 11 | ($t:ty) => { |
@@ -17,6 +17,8 @@ macro_rules! has_interner { | |||
17 | 17 | ||
18 | has_interner!(WhereClause); | 18 | has_interner!(WhereClause); |
19 | has_interner!(DomainGoal); | 19 | has_interner!(DomainGoal); |
20 | has_interner!(GenericArg); | ||
21 | has_interner!(Ty); | ||
20 | 22 | ||
21 | impl CastTo<WhereClause> for TraitRef { | 23 | impl CastTo<WhereClause> for TraitRef { |
22 | fn cast_to(self, _interner: &Interner) -> WhereClause { | 24 | fn cast_to(self, _interner: &Interner) -> WhereClause { |
@@ -36,6 +38,12 @@ impl CastTo<DomainGoal> for WhereClause { | |||
36 | } | 38 | } |
37 | } | 39 | } |
38 | 40 | ||
41 | impl CastTo<GenericArg> for Ty { | ||
42 | fn cast_to(self, interner: &Interner) -> GenericArg { | ||
43 | GenericArg::new(interner, GenericArgData::Ty(self)) | ||
44 | } | ||
45 | } | ||
46 | |||
39 | macro_rules! transitive_impl { | 47 | macro_rules! transitive_impl { |
40 | ($a:ty, $b:ty, $c:ty) => { | 48 | ($a:ty, $b:ty, $c:ty) => { |
41 | impl CastTo<$c> for $a { | 49 | impl CastTo<$c> for $a { |
@@ -51,3 +59,15 @@ macro_rules! transitive_impl { | |||
51 | 59 | ||
52 | transitive_impl!(TraitRef, WhereClause, DomainGoal); | 60 | transitive_impl!(TraitRef, WhereClause, DomainGoal); |
53 | transitive_impl!(AliasEq, WhereClause, DomainGoal); | 61 | transitive_impl!(AliasEq, WhereClause, DomainGoal); |
62 | |||
63 | macro_rules! reflexive_impl { | ||
64 | ($a:ty) => { | ||
65 | impl CastTo<$a> for $a { | ||
66 | fn cast_to(self, _interner: &Interner) -> $a { | ||
67 | self | ||
68 | } | ||
69 | } | ||
70 | }; | ||
71 | } | ||
72 | |||
73 | reflexive_impl!(GenericArg); | ||