Skip to content

Commit

Permalink
[naga] Make BlockContext::resolve_pointer_type infallible.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jimblandy authored and teoxoy committed Jun 3, 2024
1 parent 049db89 commit badcaee
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions naga/src/valid/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<crate::Expression>,
) -> Result<&crate::TypeInner, FunctionError> {
Ok(self.info[handle].ty.inner_with(self.types))
fn resolve_pointer_type(&self, handle: Handle<crate::Expression>) -> &crate::TypeInner {
self.info[handle].ty.inner_with(self.types)
}
}

Expand Down Expand Up @@ -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,
Expand All @@ -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 {
Expand Down

0 comments on commit badcaee

Please sign in to comment.