aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_ty/src/traits.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_ty/src/traits.rs')
-rw-r--r--crates/ra_hir_ty/src/traits.rs64
1 files changed, 7 insertions, 57 deletions
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs
index 2a6d7faef..3f6d2cf35 100644
--- a/crates/ra_hir_ty/src/traits.rs
+++ b/crates/ra_hir_ty/src/traits.rs
@@ -2,10 +2,9 @@
2use std::sync::Arc; 2use std::sync::Arc;
3 3
4use chalk_ir::cast::Cast; 4use chalk_ir::cast::Cast;
5use hir_def::{ 5use chalk_solve::Solver;
6 expr::ExprId, lang_item::LangItemTarget, DefWithBodyId, ImplId, TraitId, TypeAliasId, 6use hir_def::{lang_item::LangItemTarget, TraitId};
7}; 7use ra_db::CrateId;
8use ra_db::{impl_intern_key, salsa, CrateId};
9use ra_prof::profile; 8use ra_prof::profile;
10 9
11use crate::{db::HirDatabase, DebruijnIndex, Substs}; 10use crate::{db::HirDatabase, DebruijnIndex, Substs};
@@ -15,7 +14,6 @@ use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty,
15use self::chalk::{from_chalk, Interner, ToChalk}; 14use self::chalk::{from_chalk, Interner, ToChalk};
16 15
17pub(crate) mod chalk; 16pub(crate) mod chalk;
18mod builtin;
19 17
20// This controls the maximum size of types Chalk considers. If we set this too 18// This controls the maximum size of types Chalk considers. If we set this too
21// high, we can run into slow edge cases; if we set it too low, Chalk won't 19// high, we can run into slow edge cases; if we set it too low, Chalk won't
@@ -32,9 +30,10 @@ struct ChalkContext<'a> {
32 krate: CrateId, 30 krate: CrateId,
33} 31}
34 32
35fn create_chalk_solver() -> chalk_solve::Solver<Interner> { 33fn create_chalk_solver() -> chalk_recursive::RecursiveSolver<Interner> {
36 let solver_choice = chalk_solve::SolverChoice::recursive(); 34 let overflow_depth = 100;
37 solver_choice.into_solver() 35 let caching_enabled = true;
36 chalk_recursive::RecursiveSolver::new(overflow_depth, caching_enabled)
38} 37}
39 38
40/// A set of clauses that we assume to be true. E.g. if we are inside this function: 39/// A set of clauses that we assume to be true. E.g. if we are inside this function:
@@ -272,52 +271,3 @@ impl FnTrait {
272 } 271 }
273 } 272 }
274} 273}
275
276#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
277pub struct ClosureFnTraitImplData {
278 def: DefWithBodyId,
279 expr: ExprId,
280 fn_trait: FnTrait,
281}
282
283#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
284pub struct UnsizeToSuperTraitObjectData {
285 trait_: TraitId,
286 super_trait: TraitId,
287}
288
289/// An impl. Usually this comes from an impl block, but some built-in types get
290/// synthetic impls.
291#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
292pub enum Impl {
293 /// A normal impl from an impl block.
294 ImplDef(ImplId),
295 /// Closure types implement the Fn traits synthetically.
296 ClosureFnTraitImpl(ClosureFnTraitImplData),
297 /// [T; n]: Unsize<[T]>
298 UnsizeArray,
299 /// T: Unsize<dyn Trait> where T: Trait
300 UnsizeToTraitObject(TraitId),
301 /// dyn Trait: Unsize<dyn SuperTrait> if Trait: SuperTrait
302 UnsizeToSuperTraitObject(UnsizeToSuperTraitObjectData),
303}
304/// This exists just for Chalk, because our ImplIds are only unique per module.
305#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
306pub struct GlobalImplId(salsa::InternId);
307impl_intern_key!(GlobalImplId);
308
309/// An associated type value. Usually this comes from a `type` declaration
310/// inside an impl block, but for built-in impls we have to synthesize it.
311/// (We only need this because Chalk wants a unique ID for each of these.)
312#[derive(Debug, Clone, PartialEq, Eq, Hash)]
313pub enum AssocTyValue {
314 /// A normal assoc type value from an impl block.
315 TypeAlias(TypeAliasId),
316 /// The output type of the Fn trait implementation.
317 ClosureFnTraitImplOutput(ClosureFnTraitImplData),
318}
319/// This exists just for Chalk, because it needs a unique ID for each associated
320/// type value in an impl (even synthetic ones).
321#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
322pub struct AssocTyValueId(salsa::InternId);
323impl_intern_key!(AssocTyValueId);