Get rid of RIGID_AS_FLEX unification mode

This was relevant when we checked numeric ranges using unification, but
thanks to Folkert's refactoring, that is no longer necessary.
This commit is contained in:
Ayaz Hafiz 2022-06-02 20:52:41 -05:00
parent 5f5f025e4c
commit 6a447f2333
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58

View file

@ -99,13 +99,6 @@ bitflags! {
///
/// For example, t1 += [A Str] says we should "add" the tag "A Str" to the type of "t1".
const PRESENT = 1 << 1;
/// Instructs the unifier to treat rigids exactly like flex vars.
/// Usually rigids can only unify with flex vars, because rigids are named and bound
/// explicitly.
/// However, when checking type ranges, as we do for `RangedNumber` types, we must loosen
/// this restriction because otherwise an admissible range will appear inadmissible.
/// For example, Int * is in the range <I8, U8, ...>.
const RIGID_AS_FLEX = 1 << 2;
}
}
@ -126,11 +119,7 @@ impl Mode {
#[cfg(debug_assertions)]
fn pretty_print(&self) -> &str {
if self.contains(Mode::EQ | Mode::RIGID_AS_FLEX) {
"~*"
} else if self.contains(Mode::PRESENT | Mode::RIGID_AS_FLEX) {
"+=*"
} else if self.contains(Mode::EQ) {
if self.contains(Mode::EQ) {
"~"
} else if self.contains(Mode::PRESENT) {
"+="
@ -1928,19 +1917,6 @@ fn unify_rigid(
)
}
RigidVar(_)
| RecursionVar { .. }
| Structure(_)
| Alias(_, _, _, _)
| RangedNumber(..)
| LambdaSet(..)
if ctx.mode.contains(Mode::RIGID_AS_FLEX) =>
{
// Usually rigids can only unify with flex, but the mode indicates we are treating
// rigid vars as flex, so admit this.
merge(subs, ctx, *other)
}
RigidVar(_)
| RigidAbleVar(..)
| RecursionVar { .. }
@ -1990,40 +1966,6 @@ fn unify_rigid_able(
}
}
RigidVar(_)
| RecursionVar { .. }
| Structure(_)
| Alias(_, _, _, _)
| RangedNumber(..)
| LambdaSet(..)
if ctx.mode.contains(Mode::RIGID_AS_FLEX) =>
{
// Usually rigids can only unify with flex, but the mode indicates we are treating
// rigid vars as flex, so admit this.
match other {
Alias(opaque_name, vars, _real_var, AliasKind::Opaque) if vars.is_empty() => {
let mut output = merge(subs, ctx, *other);
let must_implement_ability = MustImplementAbility {
typ: Obligated::Opaque(*opaque_name),
ability,
};
output.must_implement_ability.push(must_implement_ability);
output
}
// these have underscores because they're unused in --release builds
_other => {
// For now, only allow opaque types with no type variables to implement abilities.
mismatch!(
%not_able, ctx.second, ability,
"RigidAble {:?} with non-opaque or opaque with type variables {:?}",
ctx.first,
&_other
)
}
}
}
RigidVar(_)
| RigidAbleVar(..)
| RecursionVar { .. }