Skip to content

Commit

Permalink
Fix new clippy warnings from Rust 1.84 (#13645)
Browse files Browse the repository at this point in the history
* Fix new clippy warnings from Rust 1.84

The recently release Rust 1.84 introduced some new clippy rules that are
triggering warnings in the Qiskit rust code. This commit fixes these
warnings as the point to real issues most of the time. However in this
release a bunch of the warnings are coming from a pyo3 macro that
internally had logic for a feature flag that only exists in pyo3. I
think this is likely a rule bug in clippy, but in the meantime adding a
gil-refs feature to the qiskit crates to match the feature pyo3 is using
silences the warnings.

* Fix formatting
  • Loading branch information
mtreinish authored Jan 21, 2025
1 parent 9ddb6e2 commit 3a0b0e8
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions crates/accelerate/src/remove_diagonal_gates_before_measure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,17 +61,15 @@ fn run_remove_diagonal_before_measure(dag: &mut DAGCircuit) -> PyResult<()> {
} else if DIAGONAL_2Q_GATES.contains(&gate)
|| DIAGONAL_3Q_GATES.contains(&gate)
{
let successors = dag.quantum_successors(predecessor);
let remove_s = successors
.map(|s| {
if let NodeType::Operation(inst_s) = &dag[s] {
inst_s.op.name() == "measure"
} else {
false
}
})
.all(|ok_to_remove| ok_to_remove);
if remove_s {
let mut successors = dag.quantum_successors(predecessor);
if successors.all(|s| {
let node_s = &dag.dag()[s];
if let NodeType::Operation(inst_s) = node_s {
inst_s.op.name() == "measure"
} else {
false
}
}) {
nodes_to_remove.push(predecessor);
}
}
Expand Down

0 comments on commit 3a0b0e8

Please sign in to comment.