From 049db89039a5c9ed0818ad82613b55015478bbf0 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 31 May 2024 16:14:16 -0700 Subject: [PATCH] [naga] Remove `ExpressionError::DoesntExist`. Remove `valid::expression::ExpressionError::DoesntExist`. This error is reported when expression validation encounters an invalid `Handle`, but we have already verified that the module is free of invalid handles in `Validator::validate_module_handles`, so this condition should never arise. --- naga/src/valid/expression.rs | 2 -- naga/src/valid/function.rs | 13 ++----------- 2 files changed, 2 insertions(+), 13 deletions(-) diff --git a/naga/src/valid/expression.rs b/naga/src/valid/expression.rs index adcf4b888..c6e225990 100644 --- a/naga/src/valid/expression.rs +++ b/naga/src/valid/expression.rs @@ -12,8 +12,6 @@ use crate::{ #[derive(Clone, Debug, thiserror::Error)] #[cfg_attr(test, derive(PartialEq))] pub enum ExpressionError { - #[error("Doesn't exist")] - DoesntExist, #[error("Used by a statement before it was introduced into the scope by any of the dominating blocks")] NotInScope, #[error("Base type {0:?} is not compatible with this expression")] diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index 543f71fed..f05ac3041 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -241,9 +241,7 @@ impl<'a> BlockContext<'a> { handle: Handle, valid_expressions: &BitSet, ) -> Result<&crate::TypeInner, WithSpan> { - if handle.index() >= self.expressions.len() { - Err(ExpressionError::DoesntExist.with_span()) - } else if !valid_expressions.contains(handle.index()) { + if !valid_expressions.contains(handle.index()) { Err(ExpressionError::NotInScope.with_span_handle(handle, self.expressions)) } else { Ok(self.info[handle].ty.inner_with(self.types)) @@ -263,14 +261,7 @@ impl<'a> BlockContext<'a> { &self, handle: Handle, ) -> Result<&crate::TypeInner, FunctionError> { - if handle.index() >= self.expressions.len() { - Err(FunctionError::Expression { - handle, - source: ExpressionError::DoesntExist, - }) - } else { - Ok(self.info[handle].ty.inner_with(self.types)) - } + Ok(self.info[handle].ty.inner_with(self.types)) } }