diff options
author | Florian Diebold <[email protected]> | 2020-11-20 17:00:34 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2020-12-07 10:48:58 +0000 |
commit | 78dd5482438b1ba13b4aa2eaa9a7c443a3342ce4 (patch) | |
tree | 29c3c7ffa25d23582972d58afea77da75e6a2b50 /crates/hir_ty/src/traits.rs | |
parent | a0fa522fdaf25daff6a2a9794214f0e0bedc5c24 (diff) |
Upgrade Chalk
Also make overflow depth and max type size configurable through env variables.
This can be helpful at least for debugging.
Fixes #6628.
Diffstat (limited to 'crates/hir_ty/src/traits.rs')
-rw-r--r-- | crates/hir_ty/src/traits.rs | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/crates/hir_ty/src/traits.rs b/crates/hir_ty/src/traits.rs index ce1174cbe..dfa51896b 100644 --- a/crates/hir_ty/src/traits.rs +++ b/crates/hir_ty/src/traits.rs | |||
@@ -1,4 +1,5 @@ | |||
1 | //! Trait solving using Chalk. | 1 | //! Trait solving using Chalk. |
2 | use std::env::var; | ||
2 | use std::sync::Arc; | 3 | use std::sync::Arc; |
3 | 4 | ||
4 | use base_db::CrateId; | 5 | use base_db::CrateId; |
@@ -15,12 +16,6 @@ use self::chalk::{from_chalk, Interner, ToChalk}; | |||
15 | 16 | ||
16 | pub(crate) mod chalk; | 17 | pub(crate) mod chalk; |
17 | 18 | ||
18 | // This controls the maximum size of types Chalk considers. If we set this too | ||
19 | // high, we can run into slow edge cases; if we set it too low, Chalk won't | ||
20 | // find some solutions. | ||
21 | // FIXME this is currently hardcoded in the recursive solver | ||
22 | // const CHALK_SOLVER_MAX_SIZE: usize = 10; | ||
23 | |||
24 | /// This controls how much 'time' we give the Chalk solver before giving up. | 19 | /// This controls how much 'time' we give the Chalk solver before giving up. |
25 | const CHALK_SOLVER_FUEL: i32 = 100; | 20 | const CHALK_SOLVER_FUEL: i32 = 100; |
26 | 21 | ||
@@ -31,9 +26,11 @@ struct ChalkContext<'a> { | |||
31 | } | 26 | } |
32 | 27 | ||
33 | fn create_chalk_solver() -> chalk_recursive::RecursiveSolver<Interner> { | 28 | fn create_chalk_solver() -> chalk_recursive::RecursiveSolver<Interner> { |
34 | let overflow_depth = 100; | 29 | let overflow_depth = |
30 | var("CHALK_OVERFLOW_DEPTH").ok().and_then(|s| s.parse().ok()).unwrap_or(100); | ||
35 | let caching_enabled = true; | 31 | let caching_enabled = true; |
36 | chalk_recursive::RecursiveSolver::new(overflow_depth, caching_enabled) | 32 | let max_size = var("CHALK_SOLVER_MAX_SIZE").ok().and_then(|s| s.parse().ok()).unwrap_or(30); |
33 | chalk_recursive::RecursiveSolver::new(overflow_depth, max_size, caching_enabled) | ||
37 | } | 34 | } |
38 | 35 | ||
39 | /// A set of clauses that we assume to be true. E.g. if we are inside this function: | 36 | /// A set of clauses that we assume to be true. E.g. if we are inside this function: |