Skip to content

Commit

Permalink
s/SolveCtx/SolveConfig/g
Browse files Browse the repository at this point in the history
  • Loading branch information
ayazhafiz committed Jun 22, 2023
1 parent 4f7f66d commit b5ea2c2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
6 changes: 3 additions & 3 deletions crates/compiler/load_internal/src/file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use roc_region::all::{LineInfo, Loc, Region};
#[cfg(not(target_family = "wasm"))]
use roc_reporting::report::to_https_problem_report_string;
use roc_reporting::report::{to_file_problem_report_string, Palette, RenderTarget};
use roc_solve::module::{extract_module_owned_implementations, SolveCtx, Solved, SolvedModule};
use roc_solve::module::{extract_module_owned_implementations, SolveConfig, Solved, SolvedModule};
use roc_solve_problem::TypeError;
use roc_target::TargetInfo;
use roc_types::subs::{CopiedImport, ExposedTypesStorageSubs, Subs, VarStore, Variable};
Expand Down Expand Up @@ -5121,7 +5121,7 @@ fn run_solve_solve(
let (solve_output, solved_implementations, exposed_vars_by_symbol) = {
let module_id = module.module_id;

let solve_ctx = SolveCtx {
let solve_config = SolveConfig {
home: module_id,
types,
constraints: &constraints,
Expand All @@ -5132,7 +5132,7 @@ fn run_solve_solve(
};

let solve_output = roc_solve::module::run_solve(
solve_ctx,
solve_config,
rigid_variables,
subs,
solve_aliases,
Expand Down
13 changes: 9 additions & 4 deletions crates/compiler/solve/src/module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ pub struct SolvedModule {
pub exposed_types: ExposedTypesStorageSubs,
}

pub struct SolveCtx<'a> {
pub struct SolveConfig<'a> {
/// The module we are solving.
pub home: ModuleId,
pub constraints: &'a Constraints,
Expand Down Expand Up @@ -82,7 +82,7 @@ pub struct SolveOutput {
}

pub fn run_solve(
ctx: SolveCtx<'_>,
config: SolveConfig<'_>,
rigid_variables: RigidVariables,
mut subs: Subs,
mut aliases: Aliases,
Expand All @@ -105,8 +105,13 @@ pub fn run_solve(
let mut problems = Vec::new();

// Run the solver to populate Subs.
let (solved_subs, solved_scope) =
solve::run(ctx, &mut problems, subs, &mut aliases, &mut abilities_store);
let (solved_subs, solved_scope) = solve::run(
config,
&mut problems,
subs,
&mut aliases,
&mut abilities_store,
);

SolveOutput {
subs: solved_subs,
Expand Down
12 changes: 6 additions & 6 deletions crates/compiler/solve/src/solve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::ability::{
CheckedDerives, ObligationCache, PendingDerivesTable, Resolved,
};
use crate::deep_copy::deep_copy_var_in;
use crate::module::{SolveCtx, Solved};
use crate::module::{SolveConfig, Solved};
use crate::pools::Pools;
use crate::specialize::{
compact_lambda_sets_of_vars, AwaitingSpecializations, CompactionResult, DerivedEnv, SolvePhase,
Expand Down Expand Up @@ -95,35 +95,35 @@ struct State {
}

pub fn run(
ctx: SolveCtx,
config: SolveConfig,
problems: &mut Vec<TypeError>,
mut subs: Subs,
aliases: &mut Aliases,
abilities_store: &mut AbilitiesStore,
) -> (Solved<Subs>, Scope) {
let env = run_in_place(ctx, problems, &mut subs, aliases, abilities_store);
let env = run_in_place(config, problems, &mut subs, aliases, abilities_store);

(Solved(subs), env)
}

/// Modify an existing subs in-place instead
#[allow(clippy::too_many_arguments)] // TODO: put params in a context/env var
fn run_in_place(
ctx: SolveCtx,
config: SolveConfig,
problems: &mut Vec<TypeError>,
subs: &mut Subs,
aliases: &mut Aliases,
abilities_store: &mut AbilitiesStore,
) -> Scope {
let SolveCtx {
let SolveConfig {
home: _,
constraints,
root_constraint,
mut types,
pending_derives,
exposed_by_module,
derived_module,
} = ctx;
} = config;

let mut pools = Pools::default();

Expand Down

0 comments on commit b5ea2c2

Please sign in to comment.