From 8b531fdc0257849b887022d889b79634088afb3a Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Wed, 6 Mar 2024 16:19:46 +0100 Subject: [PATCH] [wip] unify never --- gcc/rust/typecheck/rust-unify.cc | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/gcc/rust/typecheck/rust-unify.cc b/gcc/rust/typecheck/rust-unify.cc index d2c3efc701a..029e615da17 100644 --- a/gcc/rust/typecheck/rust-unify.cc +++ b/gcc/rust/typecheck/rust-unify.cc @@ -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 ()) { @@ -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); }