Skip to content

Commit 32356d9

Browse files
authored
ci: Fail on cargo check warnings (#963)
Makes sure we are signaling `cargo check` lints, fixes some "confusing lifetime" ones, and deletes an unused private struct. drive-by: Re-update `uv.lock` to `revision 2`
1 parent 99537a1 commit 32356d9

File tree

8 files changed

+650
-653
lines changed

8 files changed

+650
-653
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ jobs:
7171
needs: [changes]
7272
if: ${{ needs.changes.outputs.rust == 'true' }}
7373
runs-on: ubuntu-latest
74+
env:
75+
# Fail on rust compiler warnings.
76+
RUSTFLAGS: -D warnings
7477
steps:
7578
- uses: actions/checkout@v4
7679
- uses: mozilla-actions/sccache-action@v0.0.9

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ repos:
6565
- id: cargo-check
6666
name: cargo check
6767
description: Check rust code with `cargo check`.
68-
entry: uv run -- cargo check --all --all-features --workspace
68+
entry: env RUSTFLAGS="-Dwarnings" uv run -- cargo check --all --all-features --workspace
6969
language: system
7070
files: \.rs$
7171
pass_filenames: false

tket2-hseries/src/llvm/futures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl CodegenExtension for FuturesCodegenExtension {
5858
}
5959

6060
/// The LLVM type representing a future handle.
61-
pub fn future_type(context: &Context) -> BasicTypeEnum {
61+
pub fn future_type(context: &Context) -> BasicTypeEnum<'_> {
6262
// The runtime represent a future handle as an i64
6363
context.i64_type().into()
6464
}

tket2-hseries/src/llvm/random.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ impl CodegenExtension for RandomCodegenExtension {
3434
}
3535
}
3636

37-
fn rng_context_type(context: &Context) -> BasicTypeEnum {
37+
fn rng_context_type(context: &Context) -> BasicTypeEnum<'_> {
3838
context.struct_type(&[], false).into()
3939
}
4040

tket2-py/src/circuit/tk2circuit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl Tk2Circuit {
236236
Ok(self.clone())
237237
}
238238

239-
fn node_op(&self, node: PyNode) -> PyResult<Cow<[u8]>> {
239+
fn node_op(&self, node: PyNode) -> PyResult<Cow<'_, [u8]>> {
240240
let custom: ExtensionOp = self
241241
.circ
242242
.hugr()

tket2/src/circuit.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<T: HugrView<Node = Node>> Circuit<T> {
320320
///
321321
/// [`Tk2Op`]: crate::Tk2Op
322322
#[inline]
323-
pub fn operations(&self) -> impl Iterator<Item = Command<T>> + '_
323+
pub fn operations(&self) -> impl Iterator<Item = Command<'_, T>> + '_
324324
where
325325
Self: Sized,
326326
{

tket2/src/ops.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use hugr::{
1717
types::Signature,
1818
};
1919

20-
use derive_more::{Display, Error};
20+
use derive_more::Display;
2121
use serde::{Deserialize, Serialize};
2222
use smol_str::ToSmolStr;
2323
use strum::{EnumIter, EnumString, IntoStaticStr};
@@ -97,13 +97,6 @@ pub enum Pauli {
9797
Z,
9898
}
9999

100-
#[derive(Display, Debug, Error, PartialEq, Clone)]
101-
#[display("{} is not a Tk2Op.", op)]
102-
pub struct NotTk2Op {
103-
/// The offending operation.
104-
pub op: OpType,
105-
}
106-
107100
impl Pauli {
108101
/// Check if this pauli commutes with another.
109102
pub fn commutes_with(&self, other: Self) -> bool {

uv.lock

Lines changed: 641 additions & 640 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)