From badcaee6e33812df6023d2322ee55d6a9f992d1c Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Fri, 31 May 2024 16:23:20 -0700 Subject: [PATCH] [naga] Make `BlockContext::resolve_pointer_type` infallible. Since `BlockContext::resolve_pointer_type` never returns an error, change its result type from a `Result` to a `&TypeInner`. Adjust callers accordingly. Remove calls (well, there's only one) to `resolve_pointer_type` entirely when the caller does not need the value, since `resolve_pointer_type` is now infallible and has no side effects. --- naga/src/valid/function.rs | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/naga/src/valid/function.rs b/naga/src/valid/function.rs index f05ac3041..f112861ff 100644 --- a/naga/src/valid/function.rs +++ b/naga/src/valid/function.rs @@ -257,11 +257,8 @@ impl<'a> BlockContext<'a> { .map_err_inner(|source| FunctionError::Expression { handle, source }.with_span()) } - fn resolve_pointer_type( - &self, - handle: Handle, - ) -> Result<&crate::TypeInner, FunctionError> { - Ok(self.info[handle].ty.inner_with(self.types)) + fn resolve_pointer_type(&self, handle: Handle) -> &crate::TypeInner { + self.info[handle].ty.inner_with(self.types) } } @@ -810,9 +807,6 @@ impl super::Validator { S::Store { pointer, value } => { let mut current = pointer; loop { - let _ = context - .resolve_pointer_type(current) - .map_err(|e| e.with_span())?; match context.expressions[current] { crate::Expression::Access { base, .. } | crate::Expression::AccessIndex { base, .. } => current = base, @@ -835,9 +829,7 @@ impl super::Validator { _ => {} } - let pointer_ty = context - .resolve_pointer_type(pointer) - .map_err(|e| e.with_span())?; + let pointer_ty = context.resolve_pointer_type(pointer); let good = match *pointer_ty { Ti::Pointer { base, space: _ } => match context.types[base].inner {