Skip to content

Commit

Permalink
Fix Rustfmt and clippy with latest rust stable (#12339)
Browse files Browse the repository at this point in the history
* Fix Rustfmt and clippy with latest rust stable

Running `cargo fmt` with a newer version of rust than what we use in CI
(1.77.2 and 1.78.0 locally for me) is triggering the formatting updates
in this commit. To ensure developers don't have to worry about commiting
an accidental formatting change in their commits this commit proactively
makes the change. Similarly the recent Rust 1.78 release included new
clippy rules which are flagging some small issues that our MSRV of
clippy doesn't have. This commit also fixes these as the suggestions
are good and are compatible with our MSRV of 1.70.

* Rename deprecated config file name

* Remove dead code
  • Loading branch information
mtreinish authored May 6, 2024
1 parent 2c418aa commit c062dd6
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 12 deletions.
File renamed without changes.
4 changes: 3 additions & 1 deletion crates/accelerate/src/sparse_pauli_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,9 @@ impl ZXPaulis {
phases: &Bound<PyArray1<u8>>,
coeffs: &Bound<PyArray1<Complex64>>,
) -> PyResult<Self> {
let &[num_ops, num_qubits] = x.shape() else { unreachable!("PyArray2 must be 2D") };
let &[num_ops, num_qubits] = x.shape() else {
unreachable!("PyArray2 must be 2D")
};
if z.shape() != [num_ops, num_qubits] {
return Err(PyValueError::new_err(format!(
"'x' and 'z' have different shapes: {:?} and {:?}",
Expand Down
2 changes: 1 addition & 1 deletion crates/circuit/src/circuit_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ impl CircuitData {
0,
)?;
res.intern_context = self.intern_context.clone();
res.data = self.data.clone();
res.data.clone_from(&self.data);
Ok(res)
}

Expand Down
10 changes: 0 additions & 10 deletions crates/qasm3/src/circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ use pyo3::types::{PyList, PyString, PyTuple, PyType};
use crate::error::QASM3ImporterError;

pub trait PyRegister {
fn bit(&self, py: Python, index: usize) -> PyResult<Py<PyAny>>;
// This really should be
// fn iter<'a>(&'a self, py: Python<'a>) -> impl Iterator<Item = &'a PyAny>;
// or at a minimum
Expand All @@ -39,15 +38,6 @@ macro_rules! register_type {
}

impl PyRegister for $name {
/// Get an individual bit from the register.
fn bit(&self, py: Python, index: usize) -> PyResult<Py<PyAny>> {
// Unfortunately, `PyList::get_item_unchecked` isn't usable with the stable ABI.
self.items
.bind(py)
.get_item(index)
.map(|item| item.into_py(py))
}

fn bit_list<'a>(&'a self, py: Python<'a>) -> &Bound<'a, PyList> {
self.items.bind(py)
}
Expand Down

0 comments on commit c062dd6

Please sign in to comment.