diff options
author | Benjamin Coenen <[email protected]> | 2020-04-17 09:30:39 +0100 |
---|---|---|
committer | Benjamin Coenen <[email protected]> | 2020-04-17 09:30:39 +0100 |
commit | 0a1585075c65dd6049fc11c641309c89210e222d (patch) | |
tree | ceda5ef63d2179f25a7d5abaa16fa1dc30c9867b /crates/ra_hir_ty/src/traits.rs | |
parent | 071ef268b5c8fb9afec1db912ebcc5d6577f5e73 (diff) | |
parent | 8d296be1090b21b60e509c831864ae85feec2490 (diff) |
Merge branch 'master' of github.com:rust-analyzer/rust-analyzer
Diffstat (limited to 'crates/ra_hir_ty/src/traits.rs')
-rw-r--r-- | crates/ra_hir_ty/src/traits.rs | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 43d8d1e80..05791a848 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs | |||
@@ -16,10 +16,12 @@ use self::chalk::{from_chalk, Interner, ToChalk}; | |||
16 | pub(crate) mod chalk; | 16 | pub(crate) mod chalk; |
17 | mod builtin; | 17 | mod builtin; |
18 | 18 | ||
19 | /// This controls the maximum size of types Chalk considers. If we set this too | 19 | // This controls the maximum size of types Chalk considers. If we set this too |
20 | /// high, we can run into slow edge cases; if we set it too low, Chalk won't | 20 | // high, we can run into slow edge cases; if we set it too low, Chalk won't |
21 | /// find some solutions. | 21 | // find some solutions. |
22 | const CHALK_SOLVER_MAX_SIZE: usize = 10; | 22 | // FIXME this is currently hardcoded in the recursive solver |
23 | // const CHALK_SOLVER_MAX_SIZE: usize = 10; | ||
24 | |||
23 | /// This controls how much 'time' we give the Chalk solver before giving up. | 25 | /// This controls how much 'time' we give the Chalk solver before giving up. |
24 | const CHALK_SOLVER_FUEL: i32 = 100; | 26 | const CHALK_SOLVER_FUEL: i32 = 100; |
25 | 27 | ||
@@ -30,8 +32,7 @@ struct ChalkContext<'a> { | |||
30 | } | 32 | } |
31 | 33 | ||
32 | fn create_chalk_solver() -> chalk_solve::Solver<Interner> { | 34 | fn create_chalk_solver() -> chalk_solve::Solver<Interner> { |
33 | let solver_choice = | 35 | let solver_choice = chalk_solve::SolverChoice::recursive(); |
34 | chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE, expected_answers: None }; | ||
35 | solver_choice.into_solver() | 36 | solver_choice.into_solver() |
36 | } | 37 | } |
37 | 38 | ||
@@ -194,13 +195,16 @@ fn solve( | |||
194 | } | 195 | } |
195 | remaining > 0 | 196 | remaining > 0 |
196 | }; | 197 | }; |
197 | let mut solve = || solver.solve_limited(&context, goal, should_continue); | 198 | let mut solve = || { |
199 | let solution = solver.solve_limited(&context, goal, should_continue); | ||
200 | log::debug!("solve({:?}) => {:?}", goal, solution); | ||
201 | solution | ||
202 | }; | ||
198 | // don't set the TLS for Chalk unless Chalk debugging is active, to make | 203 | // don't set the TLS for Chalk unless Chalk debugging is active, to make |
199 | // extra sure we only use it for debugging | 204 | // extra sure we only use it for debugging |
200 | let solution = | 205 | let solution = |
201 | if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; | 206 | if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; |
202 | 207 | ||
203 | log::debug!("solve({:?}) => {:?}", goal, solution); | ||
204 | solution | 208 | solution |
205 | } | 209 | } |
206 | 210 | ||