Skip to content

Commit

Permalink
Fix clippy failures with Rust 1.67.0 (#9470)
Browse files Browse the repository at this point in the history
Rust 1.67.0 released earlier today and with it the default set of rules
in clippy changed. A new rule checking the use of the `format!()` macro
was added that triggers on some of the returned exception strings we
were using. This commit fixes this issue so that we're able to pass
clippy with the latest version of Rust.
  • Loading branch information
mtreinish authored Jan 26, 2023
1 parent 925f9f3 commit 9eb6c9b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
12 changes: 4 additions & 8 deletions src/pauli_exp_val.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ pub fn expval_pauli_no_x(
) -> PyResult<f64> {
if num_qubits >= usize::BITS as usize {
return Err(PyOverflowError::new_err(format!(
"The value for num_qubits, {}, is too large and would overflow",
num_qubits
"The value for num_qubits, {num_qubits}, is too large and would overflow"
)));
}
let data_arr = data.as_slice()?;
Expand Down Expand Up @@ -93,8 +92,7 @@ pub fn expval_pauli_with_x(
) -> PyResult<f64> {
if num_qubits > usize::BITS as usize {
return Err(PyOverflowError::new_err(format!(
"The value for num_qubits, {}, is too large and would overflow",
num_qubits
"The value for num_qubits, {num_qubits}, is too large and would overflow",
)));
}
let data_arr = data.as_slice()?;
Expand Down Expand Up @@ -149,8 +147,7 @@ pub fn density_expval_pauli_no_x(
) -> PyResult<f64> {
if num_qubits >= usize::BITS as usize {
return Err(PyOverflowError::new_err(format!(
"The value for num_qubits, {}, is too large and would overflow",
num_qubits
"The value for num_qubits, {num_qubits}, is too large and would overflow",
)));
}
let data_arr = data.as_slice()?;
Expand Down Expand Up @@ -185,8 +182,7 @@ pub fn density_expval_pauli_with_x(
) -> PyResult<f64> {
if num_qubits >= usize::BITS as usize {
return Err(PyOverflowError::new_err(format!(
"The value for num_qubits, {}, is too large and would overflow",
num_qubits
"The value for num_qubits, {num_qubits}, is too large and would overflow",
)));
}
let data_arr = data.as_slice()?;
Expand Down
3 changes: 1 addition & 2 deletions src/sabre_swap/swap_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ impl SwapMap {
match self.map.get(&object) {
Some(val) => Ok(val.clone()),
None => Err(PyIndexError::new_err(format!(
"Node index {} not in swap mapping",
object
"Node index {object} not in swap mapping",
))),
}
}
Expand Down

0 comments on commit 9eb6c9b

Please sign in to comment.