diff --git a/Cargo.lock b/Cargo.lock index b98d7afe..8e3c33e4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1148,7 +1148,7 @@ checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" [[package]] name = "quil-cli" -version = "0.6.1" +version = "0.6.2-rc.1" dependencies = [ "anyhow", "clap", @@ -1157,7 +1157,7 @@ dependencies = [ [[package]] name = "quil-py" -version = "0.13.1" +version = "0.13.2-rc.1" dependencies = [ "indexmap", "ndarray", @@ -1172,7 +1172,7 @@ dependencies = [ [[package]] name = "quil-rs" -version = "0.29.1" +version = "0.29.2-rc.1" dependencies = [ "approx", "clap", diff --git a/quil-rs/src/instruction/extern_call.rs b/quil-rs/src/instruction/extern_call.rs index ab100e2c..eb9b9650 100644 --- a/quil-rs/src/instruction/extern_call.rs +++ b/quil-rs/src/instruction/extern_call.rs @@ -80,7 +80,7 @@ impl ExternParameter { mutable: bool, data_type: ExternParameterType, ) -> Result { - validate_user_identifier(name.as_str()).map_err(ExternError::from)?; + validate_user_identifier(name.as_str()).map_err(ExternError::from_boxed)?; Ok(Self { name, mutable, @@ -151,12 +151,12 @@ pub enum ExternError { #[error( "invalid extern signature syntax: {0:?} (expected `{EXPECTED_PRAGMA_EXTERN_STRUCTURE}`)" )] - Syntax(SyntaxError), + Syntax(Box>), /// An error occurred while lexing the extern signature. #[error( "failed to lex extern signature: {0:?} (expected `{EXPECTED_PRAGMA_EXTERN_STRUCTURE}`)" )] - Lex(crate::parser::LexError), + Lex(Box), /// Pragma arguments are invalid. #[error("`PRAGMA EXTERN` must have a single argument representing the extern name")] InvalidPragmaArguments, @@ -174,7 +174,16 @@ pub enum ExternError { NoReturnOrParameters, /// Either the name of the extern or one of its parameters is invalid. #[error("invalid identifier: {0:?}")] - Name(#[from] IdentifierValidationError), + Name(#[from] Box), +} + +impl ExternError { + fn from_boxed(value: T) -> Self + where + ExternError: From>, + { + ExternError::from(Box::new(value)) + } } impl FromStr for ExternSignature { @@ -182,17 +191,20 @@ impl FromStr for ExternSignature { fn from_str(s: &str) -> Result { let signature_input = LocatedSpan::new(s); - let signature_tokens = lex(signature_input).map_err(ExternError::Lex)?; + let signature_tokens = lex(signature_input) + .map_err(Box::new) + .map_err(ExternError::Lex)?; let signature = disallow_leftover( crate::parser::pragma_extern::parse_extern_signature(signature_tokens.as_slice()) .map_err(crate::parser::ParseError::from_nom_internal_err), ) + .map_err(Box::new) .map_err(ExternError::Syntax)?; if signature.return_type.is_none() && signature.parameters.is_empty() { return Err(ExternError::NoReturnOrParameters); } for parameter in &signature.parameters { - validate_user_identifier(parameter.name.as_str()).map_err(ExternError::from)?; + validate_user_identifier(parameter.name.as_str()).map_err(ExternError::from_boxed)?; } Ok(signature) } @@ -310,7 +322,7 @@ impl TryFrom for ExternSignatureMap { match key { Some(name) => { validate_user_identifier(name.as_str()) - .map_err(ExternError::from) + .map_err(ExternError::from_boxed) .map_err(|error| (value.clone(), error))?; let signature = ExternSignature::try_from(value.clone()) .map_err(|error| (value, error))?;