From 6a447f2333c5151437a08e4114b97157dc897661 Mon Sep 17 00:00:00 2001 From: Ayaz Hafiz Date: Thu, 2 Jun 2022 20:52:41 -0500 Subject: [PATCH] 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. --- compiler/unify/src/unify.rs | 60 +------------------------------------ 1 file changed, 1 insertion(+), 59 deletions(-) diff --git a/compiler/unify/src/unify.rs b/compiler/unify/src/unify.rs index 3bce017ffd..7c35604785 100644 --- a/compiler/unify/src/unify.rs +++ b/compiler/unify/src/unify.rs @@ -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 . - 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 { .. }