diff --git a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_instructions/brillig_memory.rs b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_instructions/brillig_memory.rs index 6f0814a41eb..0b728db4af4 100644 --- a/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_instructions/brillig_memory.rs +++ b/compiler/noirc_evaluator/src/brillig/brillig_gen/brillig_instructions/brillig_memory.rs @@ -43,7 +43,7 @@ impl BrilligBlock<'_, Registers> { if data.is_empty() { return; } - let item_types = typ.clone().element_types(); + let item_types = typ.element_types(); // Find out if we are repeating the same item over and over let first_item = data.iter().take(item_types.len()).copied().collect(); diff --git a/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs b/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs index 82233385cde..b025881fac7 100644 --- a/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs +++ b/compiler/noirc_evaluator/src/ssa/interpreter/mod.rs @@ -1065,7 +1065,7 @@ impl<'ssa, W: Write> Interpreter<'ssa, W> { let is_slice = matches!(&result_type, Type::Slice(..)); // The number of elements in the array must be a multiple of the number of element types - let element_types = result_type.clone().element_types(); + let element_types = result_type.element_types(); if element_types.is_empty() { if !elements.is_empty() { return Err(internal(InternalError::MakeArrayElementCountMismatch { diff --git a/compiler/noirc_evaluator/src/ssa/ir/types.rs b/compiler/noirc_evaluator/src/ssa/ir/types.rs index 86e779c1e87..990f8a078db 100644 --- a/compiler/noirc_evaluator/src/ssa/ir/types.rs +++ b/compiler/noirc_evaluator/src/ssa/ir/types.rs @@ -221,7 +221,7 @@ impl Type { /// to represent the type. This is 1 for every primitive type, and is the number of fields /// for any flattened tuple type. /// - /// Equivalent to `self.element_types().len()`, but doesn't consume the `self`. + /// Equivalent to `self.element_types().len()`. /// /// Panics if `self` is not a [`Type::Array`] or [`Type::Slice`]. pub(crate) fn element_size(&self) -> usize { @@ -234,9 +234,9 @@ impl Type { /// Return the types of items in this array/slice. /// /// Panics if `self` is not a [`Type::Array`] or [`Type::Slice`]. - pub(crate) fn element_types(self) -> Arc> { + pub(crate) fn element_types(&self) -> Arc> { match self { - Type::Array(element_types, _) | Type::Slice(element_types) => element_types, + Type::Array(element_types, _) | Type::Slice(element_types) => element_types.clone(), other => panic!("element_types: Expected array or slice, found {other}"), } }