Fix Rustfmt and clippy with latest rust stable (#12339)

* 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
This commit is contained in:
Matthew Treinish 2024-05-06 15:08:19 -04:00 committed by GitHub
parent 2c418aa9b3
commit c062dd6cf2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 12 deletions

View File

@ -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 {:?}",

View File

@ -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)
}

View File

@ -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
@ -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)
}