mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Refactor Chalk integration some more
This commit is contained in:
parent
67a2555f6d
commit
6b5efe5bda
2 changed files with 83 additions and 79 deletions
|
@ -1,7 +1,7 @@
|
|||
//! Trait solving using Chalk.
|
||||
use std::sync::{Arc, Mutex};
|
||||
|
||||
use chalk_ir::{cast::Cast, family::ChalkIr};
|
||||
use chalk_ir::cast::Cast;
|
||||
use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId};
|
||||
use log::debug;
|
||||
use ra_db::{impl_intern_key, salsa, CrateId};
|
||||
|
@ -12,7 +12,7 @@ use crate::db::HirDatabase;
|
|||
|
||||
use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk};
|
||||
|
||||
use self::chalk::{from_chalk, ToChalk};
|
||||
use self::chalk::{from_chalk, ToChalk, TypeFamily};
|
||||
|
||||
pub(crate) mod chalk;
|
||||
mod builtin;
|
||||
|
@ -20,7 +20,7 @@ mod builtin;
|
|||
#[derive(Debug, Clone)]
|
||||
pub struct TraitSolver {
|
||||
krate: CrateId,
|
||||
inner: Arc<Mutex<chalk_solve::Solver<ChalkIr>>>,
|
||||
inner: Arc<Mutex<chalk_solve::Solver<TypeFamily>>>,
|
||||
}
|
||||
|
||||
/// We need eq for salsa
|
||||
|
@ -36,8 +36,8 @@ impl TraitSolver {
|
|||
fn solve(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<ChalkIr>>>,
|
||||
) -> Option<chalk_solve::Solution<ChalkIr>> {
|
||||
goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<TypeFamily>>>,
|
||||
) -> Option<chalk_solve::Solution<TypeFamily>> {
|
||||
let context = ChalkContext { db, krate: self.krate };
|
||||
debug!("solve goal: {:?}", goal);
|
||||
let mut solver = match self.inner.lock() {
|
||||
|
@ -201,9 +201,9 @@ pub(crate) fn trait_solve_query(
|
|||
|
||||
fn solution_from_chalk(
|
||||
db: &impl HirDatabase,
|
||||
solution: chalk_solve::Solution<ChalkIr>,
|
||||
solution: chalk_solve::Solution<TypeFamily>,
|
||||
) -> Solution {
|
||||
let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<ChalkIr>>| {
|
||||
let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<TypeFamily>>| {
|
||||
let value = subst
|
||||
.value
|
||||
.parameters
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue