From c8b2ec8c20be44ae19d15e90ff812745f029899e Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 12 Apr 2020 12:28:24 +0200 Subject: Add support for bounds on associated types in trait definitions E.g. ``` trait Trait { type Item: SomeOtherTrait; } ``` Note that these don't simply desugar to where clauses; as I understand it, where clauses have to be proved by the *user* of the trait, but these bounds are proved by the *implementor*. (Also, where clauses on associated types are unstable.) --- crates/ra_hir_ty/src/traits.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/ra_hir_ty/src/traits.rs') diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 43d8d1e80..44fbdb197 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs @@ -194,13 +194,16 @@ fn solve( } remaining > 0 }; - let mut solve = || solver.solve_limited(&context, goal, should_continue); + let mut solve = || { + let solution = solver.solve_limited(&context, goal, should_continue); + log::debug!("solve({:?}) => {:?}", goal, solution); + solution + }; // don't set the TLS for Chalk unless Chalk debugging is active, to make // extra sure we only use it for debugging let solution = if is_chalk_debug() { chalk::tls::set_current_program(db, solve) } else { solve() }; - log::debug!("solve({:?}) => {:?}", goal, solution); solution } -- cgit v1.2.3 From 14570df015d1641d1e382c9898e7c6d981b99e97 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Fri, 10 Apr 2020 17:44:43 +0200 Subject: Switch Chalk to recursive solver + various fixes related to that. --- crates/ra_hir_ty/src/traits.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'crates/ra_hir_ty/src/traits.rs') diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 44fbdb197..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}; pub(crate) mod chalk; mod builtin; -/// This controls the maximum size of types Chalk considers. If we set this too -/// high, we can run into slow edge cases; if we set it too low, Chalk won't -/// find some solutions. -const CHALK_SOLVER_MAX_SIZE: usize = 10; +// This controls the maximum size of types Chalk considers. If we set this too +// high, we can run into slow edge cases; if we set it too low, Chalk won't +// find some solutions. +// FIXME this is currently hardcoded in the recursive solver +// const CHALK_SOLVER_MAX_SIZE: usize = 10; + /// This controls how much 'time' we give the Chalk solver before giving up. const CHALK_SOLVER_FUEL: i32 = 100; @@ -30,8 +32,7 @@ struct ChalkContext<'a> { } fn create_chalk_solver() -> chalk_solve::Solver { - let solver_choice = - chalk_solve::SolverChoice::SLG { max_size: CHALK_SOLVER_MAX_SIZE, expected_answers: None }; + let solver_choice = chalk_solve::SolverChoice::recursive(); solver_choice.into_solver() } -- cgit v1.2.3