mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-01 10:52:18 +00:00
Use UEnv where possible
This commit is contained in:
parent
ad20a2ee41
commit
adf961ba0b
4 changed files with 23 additions and 17 deletions
|
@ -2,6 +2,7 @@ use bumpalo::Bump;
|
||||||
use roc_can::{constraint::Constraints, module::ExposedByModule};
|
use roc_can::{constraint::Constraints, module::ExposedByModule};
|
||||||
use roc_derive::SharedDerivedModule;
|
use roc_derive::SharedDerivedModule;
|
||||||
use roc_types::subs::{Content, Descriptor, Mark, OptVariable, Rank, Subs, Variable};
|
use roc_types::subs::{Content, Descriptor, Mark, OptVariable, Rank, Subs, Variable};
|
||||||
|
use roc_unify::unify::Env as UEnv;
|
||||||
|
|
||||||
use crate::Pools;
|
use crate::Pools;
|
||||||
|
|
||||||
|
@ -72,4 +73,9 @@ impl<'a> Env<'a> {
|
||||||
|
|
||||||
var
|
var
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Retrieves an environment for unification.
|
||||||
|
pub fn uenv<'r>(&'r mut self) -> UEnv<'r> {
|
||||||
|
UEnv::new(self.subs)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ use crate::Aliases;
|
||||||
use bumpalo::Bump;
|
use bumpalo::Bump;
|
||||||
use roc_can::abilities::{AbilitiesStore, MemberSpecializationInfo};
|
use roc_can::abilities::{AbilitiesStore, MemberSpecializationInfo};
|
||||||
use roc_can::constraint::Constraint::{self, *};
|
use roc_can::constraint::Constraint::{self, *};
|
||||||
use roc_can::constraint::{Constraints, Cycle, LetConstraint, OpportunisticResolve};
|
use roc_can::constraint::{Cycle, LetConstraint, OpportunisticResolve};
|
||||||
use roc_can::expected::{Expected, PExpected};
|
use roc_can::expected::{Expected, PExpected};
|
||||||
use roc_debug_flags::dbg_do;
|
use roc_debug_flags::dbg_do;
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
|
@ -30,8 +30,8 @@ use roc_types::subs::{
|
||||||
};
|
};
|
||||||
use roc_types::types::{Category, Polarity, Reason, RecordField, Type, TypeExtension, Types, Uls};
|
use roc_types::types::{Category, Polarity, Reason, RecordField, Type, TypeExtension, Types, Uls};
|
||||||
use roc_unify::unify::{
|
use roc_unify::unify::{
|
||||||
unify, unify_introduced_ability_specialization, Env as UEnv, Mode, Obligated,
|
unify, unify_introduced_ability_specialization, Mode, Obligated, SpecializationLsetCollector,
|
||||||
SpecializationLsetCollector, Unified::*,
|
Unified::*,
|
||||||
};
|
};
|
||||||
|
|
||||||
mod scope;
|
mod scope;
|
||||||
|
@ -484,7 +484,7 @@ fn solve(
|
||||||
);
|
);
|
||||||
|
|
||||||
match unify(
|
match unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
actual,
|
actual,
|
||||||
expected,
|
expected,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
@ -591,7 +591,7 @@ fn solve(
|
||||||
);
|
);
|
||||||
|
|
||||||
match unify(
|
match unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
actual,
|
actual,
|
||||||
expected,
|
expected,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
@ -698,7 +698,7 @@ fn solve(
|
||||||
};
|
};
|
||||||
|
|
||||||
match unify(
|
match unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
actual,
|
actual,
|
||||||
expected,
|
expected,
|
||||||
mode,
|
mode,
|
||||||
|
@ -910,7 +910,7 @@ fn solve(
|
||||||
);
|
);
|
||||||
|
|
||||||
match unify(
|
match unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
actual,
|
actual,
|
||||||
includes,
|
includes,
|
||||||
Mode::PRESENT,
|
Mode::PRESENT,
|
||||||
|
@ -1044,7 +1044,7 @@ fn solve(
|
||||||
|
|
||||||
let snapshot = env.subs.snapshot();
|
let snapshot = env.subs.snapshot();
|
||||||
let unify_cond_and_patterns_outcome = unify(
|
let unify_cond_and_patterns_outcome = unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
branches_var,
|
branches_var,
|
||||||
real_var,
|
real_var,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
@ -1094,7 +1094,7 @@ fn solve(
|
||||||
open_tag_union(env, branches_var);
|
open_tag_union(env, branches_var);
|
||||||
let almost_eq = matches!(
|
let almost_eq = matches!(
|
||||||
unify(
|
unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
real_var,
|
real_var,
|
||||||
branches_var,
|
branches_var,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
@ -1112,7 +1112,7 @@ fn solve(
|
||||||
// Case 4: incompatible types, report type error.
|
// Case 4: incompatible types, report type error.
|
||||||
// Re-run first failed unification to get the type diff.
|
// Re-run first failed unification to get the type diff.
|
||||||
match unify(
|
match unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
real_var,
|
real_var,
|
||||||
branches_var,
|
branches_var,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
@ -1311,7 +1311,7 @@ fn solve(
|
||||||
lambda_sets_to_specialize,
|
lambda_sets_to_specialize,
|
||||||
extra_metadata: _,
|
extra_metadata: _,
|
||||||
} = unify(
|
} = unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
actual,
|
actual,
|
||||||
Variable::LIST_U8,
|
Variable::LIST_U8,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
@ -1331,7 +1331,7 @@ fn solve(
|
||||||
|
|
||||||
// We explicitly match on the last unify to get the type in the case it errors.
|
// We explicitly match on the last unify to get the type in the case it errors.
|
||||||
match unify(
|
match unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
actual,
|
actual,
|
||||||
Variable::STR,
|
Variable::STR,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
@ -1574,7 +1574,7 @@ fn check_ability_specialization(
|
||||||
deep_copy_var_in(env, Rank::toplevel(), root_signature_var, env.arena);
|
deep_copy_var_in(env, Rank::toplevel(), root_signature_var, env.arena);
|
||||||
let snapshot = env.subs.snapshot();
|
let snapshot = env.subs.snapshot();
|
||||||
let unified = unify_introduced_ability_specialization(
|
let unified = unify_introduced_ability_specialization(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
root_signature_var,
|
root_signature_var,
|
||||||
symbol_loc_var.value,
|
symbol_loc_var.value,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use roc_types::{
|
||||||
},
|
},
|
||||||
types::{AliasKind, MemberImpl, Polarity, Uls},
|
types::{AliasKind, MemberImpl, Polarity, Uls},
|
||||||
};
|
};
|
||||||
use roc_unify::unify::{unify, Env as UEnv, Mode, MustImplementConstraints};
|
use roc_unify::unify::{unify, Mode, MustImplementConstraints};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ability::builtin_module_with_unlisted_ability_impl,
|
ability::builtin_module_with_unlisted_ability_impl,
|
||||||
|
@ -574,7 +574,7 @@ fn compact_lambda_set<P: Phase>(
|
||||||
// 3. Unify `t_f1 ~ t_f2`.
|
// 3. Unify `t_f1 ~ t_f2`.
|
||||||
trace_compact!(3iter_start. env.subs, this_lambda_set, t_f1, t_f2);
|
trace_compact!(3iter_start. env.subs, this_lambda_set, t_f1, t_f2);
|
||||||
let (vars, new_obligations, new_lambda_sets_to_specialize, _meta) = unify(
|
let (vars, new_obligations, new_lambda_sets_to_specialize, _meta) = unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
t_f1,
|
t_f1,
|
||||||
t_f2,
|
t_f2,
|
||||||
Mode::LAMBDA_SET_SPECIALIZATION,
|
Mode::LAMBDA_SET_SPECIALIZATION,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use roc_types::{
|
||||||
Category, ExtImplicitOpenness, Polarity, TypeTag, Types,
|
Category, ExtImplicitOpenness, Polarity, TypeTag, Types,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
use roc_unify::unify::{unify, Env as UEnv, Mode, Unified};
|
use roc_unify::unify::{unify, Mode, Unified};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
ability::{AbilityImplError, ObligationCache},
|
ability::{AbilityImplError, ObligationCache},
|
||||||
|
@ -862,7 +862,7 @@ pub(crate) fn type_to_var_help(
|
||||||
|
|
||||||
let category = Category::OpaqueArg;
|
let category = Category::OpaqueArg;
|
||||||
match unify(
|
match unify(
|
||||||
&mut UEnv::new(env.subs),
|
&mut env.uenv(),
|
||||||
var,
|
var,
|
||||||
flex_ability,
|
flex_ability,
|
||||||
Mode::EQ,
|
Mode::EQ,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue