From 3d6cbcf8a60eba97f6f2ddd4205a964ad4d458f7 Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Sun, 14 Nov 2021 12:20:27 -0800 Subject: [PATCH] Remove IndexableLength::Specializable variant. Specializable constants are no longer permitted as array lengths, so this case should not arise in valid code. --- src/back/spv/index.rs | 4 ---- src/proc/index.rs | 10 +++++----- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/back/spv/index.rs b/src/back/spv/index.rs index 0fc4c3ffe3..30ac58472f 100644 --- a/src/back/spv/index.rs +++ b/src/back/spv/index.rs @@ -109,10 +109,6 @@ impl<'w> BlockContext<'w> { let length_id = self.write_runtime_array_length(sequence, block)?; Ok(MaybeKnown::Computed(length_id)) } - crate::proc::IndexableLength::Specializable(constant) => { - let length_id = self.writer.constant_ids[constant.index()]; - Ok(MaybeKnown::Computed(length_id)) - } } } diff --git a/src/proc/index.rs b/src/proc/index.rs index 69dd6c2bba..b6dd1e4b56 100644 --- a/src/proc/index.rs +++ b/src/proc/index.rs @@ -49,10 +49,6 @@ pub enum IndexableLength { /// Values of this type always have the given number of elements. Known(u32), - /// The value of the given specializable constant is the number of elements. - /// (Non-specializable constants are reported as `Known`.) - Specializable(crate::Handle), - /// The number of elements is determined at runtime. Dynamic, } @@ -65,7 +61,11 @@ impl crate::ArraySize { K { specialization: Some(_), .. - } => IndexableLength::Specializable(k), + } => { + // Specializable constants are not supported as array lengths. + // See valid::TypeError::UnsupportedSpecializedArrayLength. + return Err(ProcError::InvalidArraySizeConstant(k)); + } ref unspecialized => { let length = unspecialized .to_array_length()