From 2a4336fe414a71653ad256964bcabd822efb4ec0 Mon Sep 17 00:00:00 2001 From: LucaCappelletti94 Date: Sun, 27 Sep 2026 23:36:40 +0200 Subject: [PATCH] fix(criterion_compat): let benches denying missing_docs compile --- .github/workflows/ci.yml | 2 ++ crates/criterion_compat/Cargo.toml | 4 ++++ crates/criterion_compat/benches/missing_docs.rs | 11 +++++++++++ crates/criterion_compat/criterion_fork/src/macros.rs | 1 + crates/criterion_compat/src/compat/macros.rs | 3 ++- 5 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 crates/criterion_compat/benches/missing_docs.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 928e7df1..c8d0f916 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -205,6 +205,8 @@ jobs: bench: criterion_integration_with_inputs - package: codspeed-criterion-compat bench: criterion_integration_measurement_overhead + - package: codspeed-criterion-compat + bench: missing_docs steps: - uses: actions/checkout@v4 with: diff --git a/crates/criterion_compat/Cargo.toml b/crates/criterion_compat/Cargo.toml index 006c9613..e25032e2 100644 --- a/crates/criterion_compat/Cargo.toml +++ b/crates/criterion_compat/Cargo.toml @@ -72,3 +72,7 @@ harness = false [[bench]] name = "custom_main" harness = false + +[[bench]] +name = "missing_docs" +harness = false diff --git a/crates/criterion_compat/benches/missing_docs.rs b/crates/criterion_compat/benches/missing_docs.rs new file mode 100644 index 00000000..9993738c --- /dev/null +++ b/crates/criterion_compat/benches/missing_docs.rs @@ -0,0 +1,11 @@ +//! Harness macros expand to items that pass `missing_docs`. +#![deny(missing_docs)] + +use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion}; + +fn sum(c: &mut Criterion) { + c.bench_function("sum", |b| b.iter(|| black_box(1u64) + 1)); +} + +criterion_group!(benches, sum); +criterion_main!(benches); diff --git a/crates/criterion_compat/criterion_fork/src/macros.rs b/crates/criterion_compat/criterion_fork/src/macros.rs index fed83d6b..8259991c 100644 --- a/crates/criterion_compat/criterion_fork/src/macros.rs +++ b/crates/criterion_compat/criterion_fork/src/macros.rs @@ -64,6 +64,7 @@ #[macro_export] macro_rules! criterion_group { (name = $name:ident; config = $config:expr; targets = $( $target:path ),+ $(,)*) => { + #[doc = "The function which runs the benchmarks."] pub fn $name() { let mut criterion: $crate::Criterion<_> = $config .configure_from_args(); diff --git a/crates/criterion_compat/src/compat/macros.rs b/crates/criterion_compat/src/compat/macros.rs index 495dea4c..02ed7143 100644 --- a/crates/criterion_compat/src/compat/macros.rs +++ b/crates/criterion_compat/src/compat/macros.rs @@ -1,6 +1,7 @@ #[macro_export] macro_rules! criterion_group { (name = $name:ident; config = $config:expr; targets = $( $target:path ),+ $(,)*) => { + #[doc = "The function which runs the benchmarks."] pub fn $name(criterion: &mut $crate::Criterion) { let mut criterion = &mut criterion.with_patched_measurement($config); $( @@ -22,7 +23,7 @@ macro_rules! criterion_group { #[macro_export] macro_rules! criterion_main { ( $( $group:path ),+ $(,)* ) => { - pub fn main() { + fn main() { let mut criterion = $crate::Criterion::new_instrumented(); $( $group(&mut criterion);