Skip to content

Commit

Permalink
[wip] unify never
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Mar 6, 2024
1 parent 3fccf65 commit 8b531fd
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions gcc/rust/typecheck/rust-unify.cc
Original file line number Diff line number Diff line change
Expand Up @@ -238,11 +238,8 @@ UnifyRules::go ()
}
}

// The never type should always get coerced to the type it's being matched
// against, so in that case, ltype. This avoids doing the same check in all
// the `expect_*` functions.
if (rtype->get_kind () == TyTy::NEVER)
return ltype->clone ();
return rtype->clone ();

switch (ltype->get_kind ())
{
Expand Down Expand Up @@ -1543,8 +1540,32 @@ UnifyRules::expect_never (TyTy::NeverType *ltype, TyTy::BaseType *rtype)
}
break;

default:
case TyTy::NEVER:
return rtype->clone ();

case TyTy::PLACEHOLDER:
case TyTy::PROJECTION:
case TyTy::DYNAMIC:
case TyTy::CLOSURE:
case TyTy::SLICE:
case TyTy::PARAM:
case TyTy::POINTER:
case TyTy::STR:
case TyTy::ADT:
case TyTy::REF:
case TyTy::ARRAY:
case TyTy::FNDEF:
case TyTy::FNPTR:
case TyTy::TUPLE:
case TyTy::BOOL:
case TyTy::CHAR:
case TyTy::INT:
case TyTy::UINT:
case TyTy::FLOAT:
case TyTy::USIZE:
case TyTy::ISIZE:
case TyTy::ERROR:
return new TyTy::ErrorType (0);
}
return new TyTy::ErrorType (0);
}
Expand Down

0 comments on commit 8b531fd

Please sign in to comment.