Skip to content

Commit d613758

Browse files
committed
fixups
Signed-off-by: sagudev <[email protected]>
1 parent 1760535 commit d613758

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

naga/src/proc/constant_evaluator.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -270,8 +270,8 @@ enum LiteralVector {
270270
}
271271

272272
impl LiteralVector {
273-
#[allow(clippy::pattern_type_mismatch)]
274-
const fn len(&self) -> usize {
273+
#[allow(clippy::pattern_type_mismatch, clippy::missing_const_for_fn)]
274+
fn len(&self) -> usize {
275275
match self {
276276
LiteralVector::F64(v) => v.len(),
277277
LiteralVector::F32(v) => v.len(),
@@ -441,7 +441,7 @@ impl LiteralVector {
441441
}
442442
}
443443

444-
/// Returns [`ArrayVec`] of [`Literals`]
444+
/// Returns [`ArrayVec`] of [`Literal`]s
445445
fn to_literal_vec(&self) -> ArrayVec<Literal, { crate::VectorSize::MAX }> {
446446
#[allow(clippy::pattern_type_mismatch)]
447447
match self {
@@ -459,13 +459,16 @@ impl LiteralVector {
459459
}
460460
}
461461

462-
fn to_expr(&self, eval: &mut ConstantEvaluator<'_>) -> Expression {
462+
fn to_expr(
463+
&self,
464+
eval: &mut ConstantEvaluator<'_>,
465+
) -> Result<Expression, ConstantEvaluatorError> {
463466
let lit_vec = self.to_literal_vec();
464467
assert!(!lit_vec.is_empty());
465468
if lit_vec.len() == 1 {
466-
Expression::Literal(lit_vec[0])
469+
Ok(Expression::Literal(lit_vec[0]))
467470
} else {
468-
Expression::Compose {
471+
Ok(Expression::Compose {
469472
ty: eval.types.insert(
470473
Type {
471474
name: None,
@@ -483,12 +486,9 @@ impl LiteralVector {
483486
),
484487
components: lit_vec
485488
.iter()
486-
.map(|&l| {
487-
eval.expressions
488-
.append(Expression::Literal(l), Span::UNDEFINED)
489-
})
490-
.collect(),
491-
}
489+
.map(|&l| eval.register_evaluated_expr(Expression::Literal(l), Span::UNDEFINED))
490+
.collect::<Result<_, _>>()?,
491+
})
492492
}
493493
}
494494

@@ -498,7 +498,7 @@ impl LiteralVector {
498498
eval: &mut ConstantEvaluator<'_>,
499499
span: Span,
500500
) -> Result<Handle<Expression>, ConstantEvaluatorError> {
501-
let expr = self.to_expr(eval);
501+
let expr = self.to_expr(eval)?;
502502
eval.register_evaluated_expr(expr, span)
503503
}
504504
}

0 commit comments

Comments
 (0)