diff options
Diffstat (limited to 'crates/ra_hir_ty/src/traits/chalk.rs')
-rw-r--r-- | crates/ra_hir_ty/src/traits/chalk.rs | 81 |
1 files changed, 39 insertions, 42 deletions
diff --git a/crates/ra_hir_ty/src/traits/chalk.rs b/crates/ra_hir_ty/src/traits/chalk.rs index 1bc0f0713..c5f1b5232 100644 --- a/crates/ra_hir_ty/src/traits/chalk.rs +++ b/crates/ra_hir_ty/src/traits/chalk.rs | |||
@@ -20,6 +20,8 @@ use crate::{ | |||
20 | ProjectionTy, Substs, TraitRef, Ty, TypeCtor, | 20 | ProjectionTy, Substs, TraitRef, Ty, TypeCtor, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | pub(super) mod tls; | ||
24 | |||
23 | #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] | 25 | #[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)] |
24 | pub struct Interner; | 26 | pub struct Interner; |
25 | 27 | ||
@@ -33,90 +35,85 @@ impl chalk_ir::interner::Interner for Interner { | |||
33 | type Identifier = TypeAliasId; | 35 | type Identifier = TypeAliasId; |
34 | type DefId = InternId; | 36 | type DefId = InternId; |
35 | 37 | ||
36 | // FIXME: implement these | ||
37 | fn debug_struct_id( | 38 | fn debug_struct_id( |
38 | _type_kind_id: chalk_ir::StructId<Self>, | 39 | type_kind_id: StructId, |
39 | _fmt: &mut fmt::Formatter<'_>, | 40 | fmt: &mut fmt::Formatter<'_>, |
40 | ) -> Option<fmt::Result> { | 41 | ) -> Option<fmt::Result> { |
41 | None | 42 | tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt))) |
42 | } | 43 | } |
43 | 44 | ||
44 | fn debug_trait_id( | 45 | fn debug_trait_id(type_kind_id: TraitId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { |
45 | _type_kind_id: chalk_ir::TraitId<Self>, | 46 | tls::with_current_program(|prog| Some(prog?.debug_trait_id(type_kind_id, fmt))) |
46 | _fmt: &mut fmt::Formatter<'_>, | ||
47 | ) -> Option<fmt::Result> { | ||
48 | None | ||
49 | } | 47 | } |
50 | 48 | ||
51 | fn debug_assoc_type_id( | 49 | fn debug_assoc_type_id(id: AssocTypeId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { |
52 | _id: chalk_ir::AssocTypeId<Self>, | 50 | tls::with_current_program(|prog| Some(prog?.debug_assoc_type_id(id, fmt))) |
53 | _fmt: &mut fmt::Formatter<'_>, | ||
54 | ) -> Option<fmt::Result> { | ||
55 | None | ||
56 | } | 51 | } |
57 | 52 | ||
58 | fn debug_alias( | 53 | fn debug_alias( |
59 | _projection: &chalk_ir::AliasTy<Self>, | 54 | alias: &chalk_ir::AliasTy<Interner>, |
60 | _fmt: &mut fmt::Formatter<'_>, | 55 | fmt: &mut fmt::Formatter<'_>, |
61 | ) -> Option<fmt::Result> { | 56 | ) -> Option<fmt::Result> { |
62 | None | 57 | tls::with_current_program(|prog| Some(prog?.debug_alias(alias, fmt))) |
63 | } | 58 | } |
64 | 59 | ||
65 | fn debug_ty(_ty: &chalk_ir::Ty<Self>, _fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { | 60 | fn debug_ty(ty: &chalk_ir::Ty<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { |
66 | None | 61 | tls::with_current_program(|prog| Some(prog?.debug_ty(ty, fmt))) |
67 | } | 62 | } |
68 | 63 | ||
69 | fn debug_lifetime( | 64 | fn debug_lifetime( |
70 | _lifetime: &chalk_ir::Lifetime<Self>, | 65 | lifetime: &chalk_ir::Lifetime<Interner>, |
71 | _fmt: &mut fmt::Formatter<'_>, | 66 | fmt: &mut fmt::Formatter<'_>, |
72 | ) -> Option<fmt::Result> { | 67 | ) -> Option<fmt::Result> { |
73 | None | 68 | tls::with_current_program(|prog| Some(prog?.debug_lifetime(lifetime, fmt))) |
74 | } | 69 | } |
75 | 70 | ||
76 | fn debug_parameter( | 71 | fn debug_parameter( |
77 | _parameter: &Parameter<Self>, | 72 | parameter: &Parameter<Interner>, |
78 | _fmt: &mut fmt::Formatter<'_>, | 73 | fmt: &mut fmt::Formatter<'_>, |
79 | ) -> Option<fmt::Result> { | 74 | ) -> Option<fmt::Result> { |
80 | None | 75 | tls::with_current_program(|prog| Some(prog?.debug_parameter(parameter, fmt))) |
81 | } | 76 | } |
82 | 77 | ||
83 | fn debug_goal(_goal: &Goal<Self>, _fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { | 78 | fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> { |
84 | None | 79 | tls::with_current_program(|prog| Some(prog?.debug_goal(goal, fmt))) |
85 | } | 80 | } |
86 | 81 | ||
87 | fn debug_goals( | 82 | fn debug_goals( |
88 | _goals: &chalk_ir::Goals<Self>, | 83 | goals: &chalk_ir::Goals<Interner>, |
89 | _fmt: &mut fmt::Formatter<'_>, | 84 | fmt: &mut fmt::Formatter<'_>, |
90 | ) -> Option<fmt::Result> { | 85 | ) -> Option<fmt::Result> { |
91 | None | 86 | tls::with_current_program(|prog| Some(prog?.debug_goals(goals, fmt))) |
92 | } | 87 | } |
93 | 88 | ||
94 | fn debug_program_clause_implication( | 89 | fn debug_program_clause_implication( |
95 | _pci: &chalk_ir::ProgramClauseImplication<Self>, | 90 | pci: &chalk_ir::ProgramClauseImplication<Interner>, |
96 | _fmt: &mut fmt::Formatter<'_>, | 91 | fmt: &mut fmt::Formatter<'_>, |
97 | ) -> Option<fmt::Result> { | 92 | ) -> Option<fmt::Result> { |
98 | None | 93 | tls::with_current_program(|prog| Some(prog?.debug_program_clause_implication(pci, fmt))) |
99 | } | 94 | } |
100 | 95 | ||
101 | fn debug_application_ty( | 96 | fn debug_application_ty( |
102 | _application_ty: &chalk_ir::ApplicationTy<Self>, | 97 | application_ty: &chalk_ir::ApplicationTy<Interner>, |
103 | _fmt: &mut fmt::Formatter<'_>, | 98 | fmt: &mut fmt::Formatter<'_>, |
104 | ) -> Option<fmt::Result> { | 99 | ) -> Option<fmt::Result> { |
105 | None | 100 | tls::with_current_program(|prog| Some(prog?.debug_application_ty(application_ty, fmt))) |
106 | } | 101 | } |
107 | 102 | ||
108 | fn debug_substitution( | 103 | fn debug_substitution( |
109 | _substitution: &chalk_ir::Substitution<Self>, | 104 | substitution: &chalk_ir::Substitution<Interner>, |
110 | _fmt: &mut fmt::Formatter<'_>, | 105 | fmt: &mut fmt::Formatter<'_>, |
111 | ) -> Option<fmt::Result> { | 106 | ) -> Option<fmt::Result> { |
112 | None | 107 | tls::with_current_program(|prog| Some(prog?.debug_substitution(substitution, fmt))) |
113 | } | 108 | } |
114 | 109 | ||
115 | fn debug_separator_trait_ref( | 110 | fn debug_separator_trait_ref( |
116 | _separator_trait_ref: &chalk_ir::SeparatorTraitRef<Self>, | 111 | separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>, |
117 | _fmt: &mut fmt::Formatter<'_>, | 112 | fmt: &mut fmt::Formatter<'_>, |
118 | ) -> Option<fmt::Result> { | 113 | ) -> Option<fmt::Result> { |
119 | None | 114 | tls::with_current_program(|prog| { |
115 | Some(prog?.debug_separator_trait_ref(separator_trait_ref, fmt)) | ||
116 | }) | ||
120 | } | 117 | } |
121 | 118 | ||
122 | fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> { | 119 | fn intern_ty(&self, ty: chalk_ir::TyData<Self>) -> Box<chalk_ir::TyData<Self>> { |