From 2bab16d3cef81b24610965f2a062a4fd536a8228 Mon Sep 17 00:00:00 2001 From: Jakub Doka Date: Fri, 25 Oct 2024 15:14:32 +0200 Subject: [PATCH] making never type cause less errors --- lang/src/lib.rs | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/lang/src/lib.rs b/lang/src/lib.rs index 81edd1f..a1b344c 100644 --- a/lang/src/lib.rs +++ b/lang/src/lib.rs @@ -398,15 +398,19 @@ mod ty { pub const DEFAULT_INT: Self = Self::UINT; pub fn is_signed(self) -> bool { - (I8..=INT).contains(&self.repr()) + (I8..=INT).contains(&self.repr()) || self.is_never() } pub fn is_unsigned(self) -> bool { - (U8..=UINT).contains(&self.repr()) + (U8..=UINT).contains(&self.repr()) || self.is_never() } pub fn is_integer(self) -> bool { - (U8..=INT).contains(&self.repr()) + (U8..=INT).contains(&self.repr()) || self.is_never() + } + + pub fn is_never(self) -> bool { + self == Self::NEVER } pub fn strip_pointer(self) -> Self { @@ -417,7 +421,7 @@ mod ty { } pub fn is_pointer(self) -> bool { - matches!(self.expand(), Kind::Ptr(_)) + matches!(self.expand(), Kind::Ptr(_)) || self.is_never() } pub fn try_upcast(self, ob: Self, kind: TyCheck) -> Option { @@ -443,11 +447,6 @@ mod ty { self.0.get() } - #[allow(unused)] - pub fn is_struct(&self) -> bool { - matches!(self.expand(), Kind::Struct(_)) - } - pub(crate) fn simple_size(&self) -> Option { Some(match self.expand() { Kind::Ptr(_) => 8,