diff --git a/Cargo.toml b/Cargo.toml index ac6feac7e684..f8ce108e4b32 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,6 +42,19 @@ qiskit-circuit = { path = "crates/circuit" } qiskit-qasm2 = { path = "crates/qasm2" } qiskit-qasm3 = { path = "crates/qasm3" } +[workspace.lints.clippy] +# The lint forbids things like `if a < b {} else if a == b {}`, and suggests matching on `a.cmp(&b)` +# which uses the `::std::cmp::Ordering` enum as a return. Both styles are acceptable, and the `if` +# chain can be more legible to people. +comparison-chain = "allow" + +[workspace.lints.rust] +# In Rust 2021, the bodies of `unsafe fn` may use `unsafe` functions themselves without marking +# them. This is an overload of the word: `unsafe fn` is documenting something for the caller, but +# that doesn't mean the entire function body is unsafe. Denying this lint (which becomes +# warn-by-default in Rust 2024) means `unsafe fn` bodies still must use `unsafe {}` like normal. +unsafe_op_in_unsafe_fn = "deny" + [profile.release] lto = 'fat' codegen-units = 1 diff --git a/crates/accelerate/Cargo.toml b/crates/accelerate/Cargo.toml index ccb4f5e0941a..439cac4a364f 100644 --- a/crates/accelerate/Cargo.toml +++ b/crates/accelerate/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true name = "qiskit_accelerate" doctest = false +[lints] +workspace = true + [dependencies] rayon.workspace = true numpy.workspace = true diff --git a/crates/accelerate/src/lib.rs b/crates/accelerate/src/lib.rs index 676730ac16bd..e26689f4f0c3 100644 --- a/crates/accelerate/src/lib.rs +++ b/crates/accelerate/src/lib.rs @@ -10,10 +10,6 @@ // copyright notice, and modified files need to carry a notice indicating // that they have been altered from the originals. -// This stylistic lint suppression should be in `Cargo.toml`, but we can't do that until we're at an -// MSRV of 1.74 or greater. -#![allow(clippy::comparison_chain)] - use std::env; use pyo3::import_exception; diff --git a/crates/accelerate/src/sparse_observable.rs b/crates/accelerate/src/sparse_observable.rs index a0393ec66d33..bce6c0572e82 100644 --- a/crates/accelerate/src/sparse_observable.rs +++ b/crates/accelerate/src/sparse_observable.rs @@ -2494,7 +2494,6 @@ impl PySparseObservable { /// >>> boundaries = np.arange(num_qubits + 1, dtype=np.uintp) /// >>> SparseObservable.from_raw_parts(num_qubits, coeffs, terms, indices, boundaries) /// - #[deny(unsafe_op_in_unsafe_fn)] #[staticmethod] #[pyo3( signature = (/, num_qubits, coeffs, bit_terms, indices, boundaries, check=true), diff --git a/crates/circuit/Cargo.toml b/crates/circuit/Cargo.toml index 8bb59e758786..54ceeb4b5bec 100644 --- a/crates/circuit/Cargo.toml +++ b/crates/circuit/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true name = "qiskit_circuit" doctest = false +[lints] +workspace = true + [dependencies] rayon.workspace = true ahash.workspace = true diff --git a/crates/pyext/Cargo.toml b/crates/pyext/Cargo.toml index eccc3ba8a87a..42962edb2fb9 100644 --- a/crates/pyext/Cargo.toml +++ b/crates/pyext/Cargo.toml @@ -10,6 +10,9 @@ name = "qiskit_pyext" doctest = false crate-type = ["cdylib"] +[lints] +workspace = true + [features] # We always need to activate PyO3's `extension-module` for this crate to be useful at all, but we # need it *not* to be active for the tests of other crates to work. If the feature is active, diff --git a/crates/qasm2/Cargo.toml b/crates/qasm2/Cargo.toml index 681693c4a17d..a6ce9c0cf6fd 100644 --- a/crates/qasm2/Cargo.toml +++ b/crates/qasm2/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true name = "qiskit_qasm2" doctest = false +[lints] +workspace = true + [dependencies] num-bigint.workspace = true hashbrown.workspace = true diff --git a/crates/qasm3/Cargo.toml b/crates/qasm3/Cargo.toml index a7be442f67e3..34bfd4304d17 100644 --- a/crates/qasm3/Cargo.toml +++ b/crates/qasm3/Cargo.toml @@ -9,6 +9,9 @@ license.workspace = true name = "qiskit_qasm3" doctest = false +[lints] +workspace = true + [dependencies] indexmap.workspace = true hashbrown.workspace = true