Skip to content

Commit a4312f7

Browse files
authored
chore: require docstrings in hugr-passes (#2391)
`missing_docs` is still allowed in `hugr-llvm` https://github.com/CQCL/hugr/blob/7902ebcf47c427dc2fc9ed74f81b78254c0724b5/hugr-llvm/src/lib.rs#L64
1 parent 26d426e commit a4312f7

File tree

9 files changed

+17
-7
lines changed

9 files changed

+17
-7
lines changed

hugr-passes/src/call_graph.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![warn(missing_docs)]
21
//! Data structure for call graphs of a Hugr
32
use std::collections::HashMap;
43

hugr-passes/src/composable.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,16 @@ use itertools::Either;
99
/// An optimization pass that can be sequenced with another and/or wrapped
1010
/// e.g. by [`ValidatingPass`]
1111
pub trait ComposablePass<H: HugrMut>: Sized {
12+
/// Error thrown by this pass.
1213
type Error: Error;
14+
/// Result returned by this pass.
1315
type Result; // Would like to default to () but currently unstable
1416

17+
/// Run the pass on the given HUGR.
1518
fn run(&self, hugr: &mut H) -> Result<Self::Result, Self::Error>;
1619

20+
/// Apply a function to the error type of this pass, returning a new
21+
/// [`ComposablePass`] that has the same result type.
1722
fn map_err<E2: Error>(
1823
self,
1924
f: impl Fn(Self::Error) -> E2,
@@ -52,7 +57,9 @@ pub trait ComposablePass<H: HugrMut>: Sized {
5257
/// Trait for combining the error types from two different passes
5358
/// into a single error.
5459
pub trait ErrorCombiner<A, B>: Error {
60+
/// Create a combined error from the first pass's error.
5561
fn from_first(a: A) -> Self;
62+
/// Create a combined error from the second pass's error.
5663
fn from_second(b: B) -> Self;
5764
}
5865

@@ -113,18 +120,25 @@ pub enum ValidatePassError<N, E>
113120
where
114121
N: HugrNode + 'static,
115122
{
123+
/// Validation failed on the initial HUGR.
116124
#[error("Failed to validate input HUGR: {err}\n{pretty_hugr}")]
117125
Input {
126+
/// The validation error that occurred.
118127
#[source]
119128
err: ValidationError<N>,
129+
/// A pretty-printed representation of the HUGR that failed validation.
120130
pretty_hugr: String,
121131
},
132+
/// Validation failed on the final HUGR.
122133
#[error("Failed to validate output HUGR: {err}\n{pretty_hugr}")]
123134
Output {
135+
/// The validation error that occurred.
124136
#[source]
125137
err: ValidationError<N>,
138+
/// A pretty-printed representation of the HUGR that failed validation.
126139
pretty_hugr: String,
127140
},
141+
/// An error from the underlying pass.
128142
#[error(transparent)]
129143
Underlying(#[from] E),
130144
}
@@ -134,6 +148,7 @@ where
134148
pub struct ValidatingPass<P, H>(P, PhantomData<H>);
135149

136150
impl<P: ComposablePass<H>, H: HugrMut> ValidatingPass<P, H> {
151+
/// Return a new [`ValidatingPass`] that wraps the given underlying pass.
137152
pub fn new(underlying: P) -> Self {
138153
Self(underlying, PhantomData)
139154
}

hugr-passes/src/const_fold.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![warn(missing_docs)]
21
//! Constant-folding pass.
32
//! An (example) use of the [dataflow analysis framework](super::dataflow).
43

hugr-passes/src/dataflow.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![warn(missing_docs)]
21
//! Dataflow analysis of Hugrs.
32
43
mod datalog;

hugr-passes/src/dead_funcs.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![warn(missing_docs)]
21
//! Pass for removing statically-unreachable functions from a Hugr
32
43
use std::collections::HashSet;

hugr-passes/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//! Compilation passes acting on the HUGR program representation.
2-
#![expect(missing_docs)] // TODO: Fix...
32
43
pub mod call_graph;
54
pub mod composable;

hugr-passes/src/lower.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//! Passes to lower operations in a HUGR.
2+
13
use hugr_core::{
24
Hugr, Node,
35
hugr::{hugrmut::HugrMut, views::SiblingSubgraph},

hugr-passes/src/non_local.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
//! This module provides functions for finding non-local edges
22
//! in a Hugr and converting them to local edges.
3-
#![warn(missing_docs)]
43
use itertools::Itertools as _;
54

65
use hugr_core::{

hugr-passes/src/replace_types.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![allow(clippy::type_complexity)]
2-
#![warn(missing_docs)]
32
//! Replace types with other types across the Hugr. See [`ReplaceTypes`] and [Linearizer].
43
//!
54
use std::borrow::Cow;

0 commit comments

Comments
 (0)