Skip to content

Commit

Permalink
fix: box pragma returned in error
Browse files Browse the repository at this point in the history
  • Loading branch information
erichulburd committed Nov 1, 2024
1 parent 97cae32 commit fd4c817
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions quil-rs/src/instruction/extern_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ pub struct ExternSignatureMap(IndexMap<String, ExternSignature>);
impl TryFrom<ExternPragmaMap> for ExternSignatureMap {
/// The error type for converting an [`ExternPragmaMap`] to an [`ExternSignatureMap`] includes
/// the offending [`Pragma`] instruction and the error that occurred.
type Error = (Pragma, ExternError);
type Error = (Box<Pragma>, ExternError);

fn try_from(value: ExternPragmaMap) -> Result<Self, Self::Error> {
Ok(ExternSignatureMap(
Expand All @@ -311,12 +311,12 @@ impl TryFrom<ExternPragmaMap> for ExternSignatureMap {
Some(name) => {
validate_user_identifier(name.as_str())
.map_err(ExternError::from)
.map_err(|error| (value.clone(), error))?;
.map_err(|error| (Box::new(value.clone()), error))?;
let signature = ExternSignature::try_from(value.clone())
.map_err(|error| (value, error))?;
.map_err(|error| (Box::new(value), error))?;
Ok((name, signature))
}
_ => Err((value, ExternError::NoName)),
_ => Err((Box::new(value), ExternError::NoName)),
}
})
.collect::<Result<_, Self::Error>>()?,
Expand Down
2 changes: 1 addition & 1 deletion quil-rs/src/program/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ impl Program {
/// with the offending [`Pragma`].
pub fn try_extern_signature_map_from_pragma_map(
&self,
) -> std::result::Result<ExternSignatureMap, (Pragma, ExternError)> {
) -> std::result::Result<ExternSignatureMap, (Box<Pragma>, ExternError)> {

Check failure on line 768 in quil-rs/src/program/mod.rs

View workflow job for this annotation

GitHub Actions / Clippy (stable)

the `Err`-variant returned from this function is very large
ExternSignatureMap::try_from(self.extern_pragma_map.clone())
}
}
Expand Down
2 changes: 1 addition & 1 deletion quil-rs/src/program/scheduling/graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl<'a> ScheduledBasicBlock<'a> {
let extern_signature_map = ExternSignatureMap::try_from(program.extern_pragma_map.clone())
.map_err(|(pragma, _)| ScheduleError {
instruction_index: None,
instruction: Instruction::Pragma(pragma),
instruction: Instruction::Pragma(*pragma),
variant: ScheduleErrorVariant::Extern,
})?;
for (index, &instruction) in basic_block.instructions().iter().enumerate() {
Expand Down

0 comments on commit fd4c817

Please sign in to comment.