Skip to content

refactor(ohno_macros,observed_macros): split implementations into *_macros_impl - #682

Open
Evgenii (Vaiz) wants to merge 8 commits into
mainfrom
split-macros-impl
Open

refactor(ohno_macros,observed_macros): split implementations into *_macros_impl#682
Evgenii (Vaiz) wants to merge 8 commits into
mainfrom
split-macros-impl

Conversation

@Vaiz

@Vaiz Evgenii (Vaiz) commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Adopt the Microsoft Rust guideline's three-crate proc-macro model (M-MACRO-PROC-IMPL), matching the existing in-repo precedent used by fundle, data_privacy, internity, multitude, templated_uri and thread_aware.

  • Add ohno_macros_impl 0.4.0 and observed_macros_impl 0.24.0 as ordinary library crates holding all implementation modules, wired through [workspace.dependencies] with matching path + version, as the sibling *_macros_impl crates are.
  • Reduce ohno_macros and observed_macros to thin proc-macro shims that only convert proc_macro::TokenStream to proc_macro2::TokenStream, delegate, and convert back. Macro names, attributes(...) lists and all rustdoc on the entry points are unchanged.
  • Move the inline unit and insta snapshot tests into the new crates' tests/ directories with their snapshots in tests/snapshots/, renaming the snapshot files to match their new module paths. No snapshot body changed.
  • Widen visibility of the moved items where the new crate boundary forces it; the modules are #[doc(hidden)] because they are reachable only for these tests.
  • Register the new crates in the root CHANGELOG, .anvil.lock, scripts/mutants.rs and the CI miri exclusion list, and give each shim the coverage-gate opt-out the other proc-macro shims carry.

🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.

Update — the open question in this description is now resolved.

The description above offered to switch the crate-level expect(must_use_candidate, missing_debug_implementations) in ohno_macros_impl to per-item attributes. That has been done in 4e2d9f97, so there is nothing left to decide here:

  • #[must_use] on the 42 flagged functions.
  • #[derive(Debug)] on the 17 flagged types, rather than excusing them.
  • clippy::too_long_first_doc_paragraph on numeric_kind satisfied by a paragraph break (same words), not excused.
  • Both new crates now handle this identically; observed_macros_impl previously used per-item expect while ohno_macros_impl used a crate-level one.

Two lints in the moved test bodies (clippy::assertions_on_result_states, clippy::err_expect) surfaced once that code left a proc-macro crate's unit-test target for an ordinary crate's integration-test target. Both are fixed the way clippy asks — assert!(x.is_err())expect_err, .err().expect(..).expect_err(..) — which is what the surrounding tests already used.

Unrelated mutants dev-dependency flagged by cargo udeps was removed from ohno_macros_impl in da89690c; observed_macros_impl keeps it because its moved event coverage tests genuinely use mutants::skip.


CI fixes on top of the split (2026-08-19)

Two gates failed once the tests moved out of the proc-macro crate. Both are consequences of the move, and both are fixed by matching what observed_macros_impl and the other *_macros_impl crates already do — no behaviour, no macro output and no snapshot body changed.

anvil-miri — the snapshot tests now live in a normal library crate, so cargo miri test --tests runs them. insta's get_cargo_workspace reads from disk and miri's isolation rejects it (unsupported operation: open not available when isolation is enabled). Inside the old proc-macro crate miri never reached these tests. The five insta-using modules are now #[cfg(all(test, not(miri)))], the same guard observed_macros_impl carries in this PR and templated_uri_macros_impl carries on main. Test files without snapshots keep running under miri.

anvil-llvm-cov — the moved tests call the inner module functions directly, so nothing exercised derive_error, enrich_err and error in ohno_macros_impl/src/lib.rs. llvm-cov measured that file at 0% of 20 lines, putting the package below the 100% line threshold. Rather than excuse it, the entry points are now covered: unlike the proc-macro shim they take proc_macro2::TokenStream, so a test can call them, and both arms of each (expanded vs. reported) are exercised. lib.rs goes from 0% to 100%. This keeps the per-item-compliance-over-suppression approach used elsewhere in this PR; min-lines-percent = 0 remains only on the proc-macro shims, which genuinely cannot be unit-tested.

anvil-mutants-diff — two surviving mutants, both replacing an entry point body with Ok(Default::default()): observed_macros_impl::event and observed_macros_impl::derive_enrichment. Same root cause as the coverage gap above and confined to the same kind of code: the moved tests reach the logic through internals::*, so nothing called the crate's own entry points and returning an empty TokenStream from either went unnoticed. Both are now called directly with assertions on the expansion, which a Default::default() return fails.


Review round 1 — automated reviewer (2026-08-19)

Root CHANGELOG.md index — accepted in part. observed_macros_impl was missing from the index and is added in 0ae05d47. observed and observed_macros also ship changelogs and are also absent from that index, but on main as well; that omission predates this PR and is left for a separate change. .anvil.lock needs no observed_macros_impl entry: the observed crates carry no anvil-managed lints region, so the whole family is absent from that file on main.

scripts/mutants.rs TEST_GROUPS — declined, out of scope. main has no observed group; observed and observed_macros are already tested individually. This PR extended the group that existed (adding ohno_macros_impl to the ohno group). Creating a new group would change mutation testing for two untouched crates. The risk the grouping comment guards against does not apply here: observed_macros_impl's tests live in observed_macros_impl, and anvil-mutants-diff passes on 642ae105 with the crate ungrouped, after tests/entry_points.rs closed the two missed mutants seen on 26311502.

_ = ... in crates/observed_macros_impl/tests/entry_points.rs — declined, incorrect. _ = expr; is valid Rust (destructuring assignment, stable since 1.59) and is an expression statement, not a let binding. The file compiles and runs in the testing, coverage and pr-mutants jobs, all green on 642ae105.

@github-actions

github-actions Bot commented Aug 19, 2026

Copy link
Copy Markdown

✅ Version increments look sufficient

cargo semver-checks compared the 2 crate(s) this PR publishes against their previous version-bump commit in git history. Every version increment is sufficient for the detected API changes.

Crate Baseline Baseline commit This PR Minimum required Status
observed_macros_impl new crate 0.24.0 0.24.0 ✅ ok
ohno_macros_impl new crate 0.4.0 0.4.0 ✅ ok

This check is informational and does not block the merge.

View the check run

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (a6ca774) to head (0ae05d4).

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #682    +/-   ##
========================================
  Coverage   100.0%   100.0%            
========================================
  Files         554      556     +2     
  Lines       61509    60664   -845     
========================================
- Hits        61509    60664   -845     
Flag Coverage Δ
linux 94.7% <100.0%> (?)
linux-arm 94.3% <100.0%> (?)
windows 95.7% <100.0%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Vaiz
Evgenii (Vaiz) marked this pull request as ready for review August 19, 2026 16:31
Copilot AI lite review requested due to automatic review settings August 19, 2026 16:31

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Refactors the ohno_macros and observed_macros proc-macro crates to follow the workspace’s three-crate proc-macro model by moving implementation code into new *_macros_impl library crates, leaving the proc-macro crates as thin TokenStream conversion/delegation shims. The PR also relocates unit/insta snapshot tests into integration tests under the new impl crates and updates CI/coverage/mutation-testing configuration to match existing in-repo precedent.

Changes:

  • Added ohno_macros_impl and observed_macros_impl as new library crates and rewired ohno_macros / observed_macros to delegate to them.
  • Moved macro implementation modules + tests (including insta snapshots) into the new impl crates.
  • Updated workspace wiring (workspace deps, lockfile, CI miri exclusions, and mutation-testing grouping) to account for the new crate boundaries.

Reviewed changes

Copilot reviewed 62 out of 162 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
scripts/mutants.rs Adds ohno_macros_impl to the ohno mutation-testing group.
crates/ohno_macros/src/marker.rs Removes marker implementation/tests from the proc-macro crate (moved to impl crate).
crates/ohno_macros/src/lib.rs Converts to a thin proc-macro shim delegating to ohno_macros_impl.
crates/ohno_macros/Cargo.toml Replaces syn/quote/proc-macro2 deps with ohno_macros_impl; opts out of per-crate coverage gate for proc-macro shim.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__other_attributes_and_docs_survive.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__no_constructors_is_rejected.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__an_ordinary_doc_comment_is_left_alone.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__a_unit_struct_becomes_a_tuple_struct.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__a_tuple_struct_gains_a_trailing_core.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__a_non_struct_is_rejected.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__a_named_struct_gains_a_named_core.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__a_marked_field_is_rejected.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__a_hand_written_reserved_marker_is_rejected.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/error_attr__tests__a_colliding_name_is_numbered.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__the_signature_survives_untouched.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__the_body_runs_inside_a_closure.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__arguments_are_passed_through_unchanged.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__an_inline_capture_goes_through_format.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__an_async_function_awaits_an_async_block.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__a_self_prefixed_argument_is_left_alone.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__a_non_literal_first_argument_is_rejected.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__a_non_function_is_rejected.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__a_missing_return_type_is_rejected.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__a_literal_message_renders_without_format.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/enrich_err__tests__a_bare_attribute_names_the_function.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__the_suppressing_flags_remove_their_items.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__generics_thread_through_every_impl.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__conversions_initialize_every_non_core_field.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__a_tuple_struct_generates_positional_items.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__a_single_field_struct_takes_no_constructor_parameters.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__a_named_struct_generates_every_item.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__a_message_overrides_the_default.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_generate__tests__a_core_in_the_middle_keeps_declaration_order.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__too_few_arguments_are_reported.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__the_added_core_is_not_referenceable.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__nothing_is_referenceable_when_every_field_is_generated.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__every_fault_in_one_template_is_reported_together.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__escapes_are_resolved_for_a_literal_message.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__an_unsupported_argument_root_is_reported.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__an_unknown_placeholder_lists_the_available_fields.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__an_unknown_argument_root_is_reported.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__an_unconsumed_argument_is_reported.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__an_unbalanced_brace_stops_the_lowering.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__an_argument_may_call_a_method_of_self.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_tuple_field_is_named_by_index.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_stray_closing_brace_stops_the_lowering.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_static_template_lowers_to_a_literal.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_self_prefixed_argument_is_reported.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_raw_identifier_is_offered_with_its_prefix.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_positional_argument_is_scoped_and_parenthesized.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_named_placeholder_becomes_a_field_access.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_format_spec_survives_lowering.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_declared_core_stays_referenceable.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error_display__tests__a_declared_core_is_offered_as_an_available_field.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error__tests__the_suppressing_flags_remove_their_items.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error__tests__a_valid_shape_with_an_invalid_template_generates_nothing.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error__tests__a_valid_input_expands_to_every_item.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/snapshots/derive_error__tests__a_rejected_input_expands_to_diagnostics_only.snap Snapshot relocated/renamed under impl crate tests.
crates/ohno_macros_impl/tests/message.rs New integration tests for message module behavior.
crates/ohno_macros_impl/tests/marker.rs New integration tests for reserved marker behavior.
crates/ohno_macros_impl/tests/error_attr.rs New integration tests for #[ohno::error] rewriting with insta snapshots (miri-gated).
crates/ohno_macros_impl/tests/entry_points.rs New integration tests to cover impl-crate entry points for coverage/mutants.
crates/ohno_macros_impl/tests/enrich_err.rs New integration tests for #[enrich_err] expansion with insta snapshots (miri-gated).
crates/ohno_macros_impl/tests/diagnostics.rs New integration tests for diagnostics accumulation/rendering.
crates/ohno_macros_impl/tests/derive_error.rs Converts derive-error tests to integration tests calling impl-crate code (miri-gated).
crates/ohno_macros_impl/tests/derive_error_validate.rs Converts validate-phase tests to integration tests using impl-crate internals.
crates/ohno_macros_impl/tests/derive_error_generate.rs Converts generate-phase tests to integration tests using impl-crate internals (miri-gated).
crates/ohno_macros_impl/tests/derive_error_display_template.rs New integration tests for display template splitting/lowering.
crates/ohno_macros_impl/tests/derive_error_display_argument.rs New integration tests for display argument rooting logic.
crates/ohno_macros_impl/src/paths.rs Widens visibility + adds #[must_use] for path token constructors.
crates/ohno_macros_impl/src/message.rs Widens visibility; derives Debug; adds #[must_use]; moves tests into integration tests.
crates/ohno_macros_impl/src/marker.rs New module hosting reserved-marker logic (moved from proc-macro crate).
crates/ohno_macros_impl/src/lib.rs New impl-crate root: exposes doc-hidden modules for integration tests + provides entry points.
crates/ohno_macros_impl/src/error_attr/mod.rs Makes expand public + #[must_use]; removes inline unit tests.
crates/ohno_macros_impl/src/enrich_err/mod.rs Makes expand public + #[must_use]; removes inline unit tests.
crates/ohno_macros_impl/src/diagnostics.rs Makes Errors public + Debug + #[must_use]; removes inline unit tests.
crates/ohno_macros_impl/src/derive_error/mod.rs New derive implementation module root with public expand.
crates/ohno_macros_impl/src/derive_error/generate/traits.rs Widens visibility + adds #[must_use] on generated impl emitters.
crates/ohno_macros_impl/src/derive_error/generate/mod.rs New module for token generation phase.
crates/ohno_macros_impl/src/derive_error/generate/conversions.rs Widens visibility + adds #[must_use].
crates/ohno_macros_impl/src/derive_error/generate/constructors.rs Widens visibility + adds #[must_use].
crates/ohno_macros_impl/src/derive_error/display/argument.rs New module for rooting positional display arguments.
crates/ohno_macros_impl/src/derive_error/ast.rs Widens visibility + derives Debug + adds #[must_use] where applicable.
crates/ohno_macros_impl/README.md New crate README.
crates/ohno_macros_impl/logo.png New crate asset (Git LFS tracked).
crates/ohno_macros_impl/favicon.ico New crate asset (Git LFS tracked).
crates/ohno_macros_impl/CHANGELOG.md New crate changelog.
crates/ohno_macros_impl/Cargo.toml New crate manifest.
crates/observed_macros/src/lib.rs Converts to a thin proc-macro shim delegating to observed_macros_impl.
crates/observed_macros/Cargo.toml Replaces syn/quote/proc-macro2 deps with observed_macros_impl; opts out of per-crate coverage gate for proc-macro shim.
crates/observed_macros_impl/tests/snapshots/event__tests__updowncounter_with_signed_field.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__unit_struct_event.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__option_field_filled_when_none.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__option_field_drop_when_none.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__option_field_custom_fill_when_none.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__option_dimension_filled_when_none.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__no_signal.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__metric_value_field_can_exclude_from_log.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__log_name_override.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_where_clause.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_type_parameter.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_reference_to_redactable_type.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_parenthesized_reference.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_message.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_lifetime.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_field_metric.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_field_attrs.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_with_data_class.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_metric_only.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_field_metric_only.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__event_all_attributes.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__error_message_references_nonexistent_attr.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__error_message_references_field_name_not_attr_name.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__error_message_references_excluded_field.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__disabled_event.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__dimension_separate_log_and_metric_keys.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__dimension_metric_only_excludes_log.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__dimension_metric_keeps_default_log.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__dimension_metric_bare_opts_in_own_name.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__dimension_exclude_log_with_bare_metric.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__dimension_bare_logs_under_own_name.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__counter_with_unsigned_field.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/event__tests__basic_event.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_with_type_parameter.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_with_rename.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_with_lifetime.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_with_lifetime_and_type_parameter.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_with_dimension.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_with_data_class.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_option_field_filled_when_none.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_option_field_drop_when_none.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_exclude_from_logs.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__enrichment_all_attributes.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/snapshots/enrichment__tests__basic_enrichment.snap Snapshot relocated/renamed under impl crate tests.
crates/observed_macros_impl/tests/field_attrs.rs New integration coverage tests for internal type helpers.
crates/observed_macros_impl/tests/entry_points.rs New integration tests for impl-crate entry points (mutation/coverage driven).
crates/observed_macros_impl/src/lib.rs New impl-crate root exposing entry points and doc-hidden internals for tests.
crates/observed_macros_impl/src/field_attrs.rs Widens visibility + adds #[must_use]; removes inline coverage tests.
crates/observed_macros_impl/README.md New crate README.
crates/observed_macros_impl/logo.png New crate asset (Git LFS tracked).
crates/observed_macros_impl/favicon.ico New crate asset (Git LFS tracked).
crates/observed_macros_impl/CHANGELOG.md New crate changelog.
crates/observed_macros_impl/Cargo.toml New crate manifest.
CHANGELOG.md Adds a link for ohno_macros_impl (but not observed_macros_impl).
Cargo.toml Registers observed_macros_impl and ohno_macros_impl under [workspace.dependencies].
Cargo.lock Updates dependency graph to include the new impl crates.
.github/workflows/main.yml Excludes observed_macros_impl and ohno_macros_impl from miri job.
.anvil.lock Registers ohno_macros_impl for anvil-managed lints.
Suppressed comments (1)

crates/observed_macros_impl/tests/entry_points.rs:62

  • _ = ... is invalid statement syntax in Rust and will fail to compile in this test. You can just call expect_err(...) (or use let _ = ...).
    fn derive_enrichment_reports_an_unparsable_input() {
        _ = derive_enrichment(quote!(1 + 1)).expect_err("a non-derive-input is rejected");
    }

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread CHANGELOG.md
Comment on lines 29 to 33
- [`multitude`](./crates/multitude/CHANGELOG.md)
- [`ohno`](./crates/ohno/CHANGELOG.md)
- [`ohno_macros`](./crates/ohno_macros/CHANGELOG.md)
- [`ohno_macros_impl`](./crates/ohno_macros_impl/CHANGELOG.md)
- [`plurality`](./crates/plurality/CHANGELOG.md)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.

Accepted in part, and fixed in 0ae05d47: observed_macros_impl is now listed in the root CHANGELOG.md index. You are right that the description's registration claim was only half true — ohno_macros_impl was added and the new observed counterpart was not.

Declined for the rest: observed and observed_macros both ship a CHANGELOG.md and neither is listed in this index on main — that omission predates this PR and belongs in a separate fix, not in a macro-split refactor.

For the record, .anvil.lock is a different case and is correct as-is: it contains no observed* entries at all on main, because the observed crates carry no anvil-managed lints region, so observed_macros_impl is consistently absent there too.

Comment thread scripts/mutants.rs
Comment on lines 43 to 47
&["data_privacy", "data_privacy_core", "data_privacy_macros", "data_privacy_macros_impl"],
&["fundle", "fundle_macros", "fundle_macros_impl"],
&["ohno", "ohno_macros"],
&["ohno", "ohno_macros", "ohno_macros_impl"],
&["templated_uri", "templated_uri_macros", "templated_uri_macros_impl"],
&["thread_aware", "thread_aware_macros", "thread_aware_macros_impl"],

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.

Declined, as out of scope.

main has no observed group in TEST_GROUPS at all — observed and observed_macros are already tested individually there. This PR extended the group that existed (ohno, ohno_macros → plus ohno_macros_impl); creating a brand-new ["observed", "observed_macros", "observed_macros_impl"] group would change how mutation testing runs for two crates this PR does not touch, and that is a decision for a change aimed at the observed family.

The concrete worry the grouping comment guards against — mutants surviving because the killing tests live in a dependent package — does not apply to the new crate: observed_macros_impl's tests live in observed_macros_impl. That was verified rather than assumed. anvil-mutants-diff failed on 26311502 with exactly two missed mutants (event and derive_enrichment replaced by Ok(Default::default())), crates/observed_macros_impl/tests/entry_points.rs was added to call both entry points directly, and the gate passed on 642ae105 with the crate still ungrouped.

Comment on lines +39 to +41
fn event_reports_an_unparsable_item() {
_ = event(quote!("http.request"), quote!(1 + 1)).expect_err("a non-item is rejected");
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 Clawpilot here! Posted automatically by Clawpilot (an AI agent), not by a human. Please verify before acting.

Declined — this is incorrect. _ = expr; is valid Rust: destructuring assignment to the wildcard pattern was stabilized in Rust 1.59, and _ = ...; is an expression statement, not a let binding. It is the idiomatic way to discard a #[must_use] value without naming a binding.

The evidence is in this PR's own CI rather than in an argument: crates/observed_macros_impl/tests/entry_points.rs is compiled and run by the testing, coverage and pr-mutants jobs, all of which are green on 642ae105. A file that failed to compile could not have produced the coverage and mutation results this PR relies on.

Lines 41 and 60 are unchanged for that reason.

Evgenii (Vaiz) and others added 8 commits August 19, 2026 18:03
…acros_impl

Adopt the Microsoft Rust guideline's three-crate proc-macro model
(M-MACRO-PROC-IMPL), matching the existing in-repo precedent used by
`fundle`, `data_privacy`, `internity`, `multitude`, `templated_uri` and
`thread_aware`.

- Add `ohno_macros_impl` 0.4.0 and `observed_macros_impl` 0.24.0 as ordinary
  library crates holding all implementation modules, wired through
  `[workspace.dependencies]` with matching path + version, as the sibling
  `*_macros_impl` crates are.
- Reduce `ohno_macros` and `observed_macros` to thin `proc-macro` shims that
  only convert `proc_macro::TokenStream` to `proc_macro2::TokenStream`,
  delegate, and convert back. Macro names, `attributes(...)` lists and all
  rustdoc on the entry points are unchanged.
- Move the inline unit and insta snapshot tests into the new crates' `tests/`
  directories with their snapshots in `tests/snapshots/`, renaming the
  snapshot files to match their new module paths. No snapshot body changed.
- Widen visibility of the moved items where the new crate boundary forces it;
  the modules are `#[doc(hidden)]` because they are reachable only for these
  tests.
- Register the new crates in the root CHANGELOG, `.anvil.lock`,
  `scripts/mutants.rs` and the CI miri exclusion list, and give each shim the
  `coverage-gate` opt-out the other proc-macro shims carry.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`just readme` drives `cargo doc2readme --lib --template ../README.j2`, so the
README body has to be the generated rendering of the crate-level docs. The
hand-written body drifted from `src/lib.rs`; regenerate it so
`just readme-check` passes. `observed_macros_impl`, `ohno_macros` and
`observed_macros` were already up to date.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`cargo udeps` flagged it, correctly: the `#[cfg_attr(test, mutants::skip)]`
attributes it backed sit on the `#[proc_macro*]` entry points, which stayed in
the `ohno_macros` shim. Nothing in `ohno_macros_impl` references `mutants`.
`observed_macros_impl` keeps it, because its moved `event` coverage tests still
use `mutants::skip`.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…tem, not per crate

Moving the unit tests into `tests/` forced the items they exercise to become
`pub`, which woke `clippy::must_use_candidate` and `missing_debug_implementations`
— both only fire on publicly reachable items, so neither had fired before. The
first pass silenced them with crate-level `expect` attributes. Comply with the
lints instead:

- Add `#[must_use]` to the 42 flagged functions.
- Derive `Debug` on the 17 flagged types rather than excusing them.
- Split the first `numeric_kind` doc paragraph (same words, one paragraph break)
  so `clippy::too_long_first_doc_paragraph` is satisfied rather than excused.

This also makes the two new crates consistent: `observed_macros_impl` was using
per-item `expect(missing_debug_implementations)` while `ohno_macros_impl` used a
crate-level one.

Two lints in the moved test bodies surfaced once the code left a `proc-macro`
crate's unit-test target for an ordinary crate's integration-test target, and are
fixed the way clippy asks: `assert!(x.is_err())` becomes `expect_err`, and
`.err().expect(..)` becomes `.expect_err(..)`. Both are exactly equivalent, and
`expect_err` is what the surrounding tests already use.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The moved snapshot tests now live in a normal library crate, so `cargo miri test --tests`
runs them, where insta's `get_cargo_workspace` hits `unsupported operation: open not
available when isolation is enabled` and fails `anvil-miri`. Inside the old proc-macro
crate miri never reached them.

Guard the five insta-using modules with `#[cfg(all(test, not(miri)))]`, matching what
`observed_macros_impl` already does in this same change and `templated_uri_macros_impl`
does on main. Files without snapshots keep running under miri.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The moved tests call the inner module functions directly, so nothing exercised
`derive_error`, `enrich_err` and `error` in `lib.rs`: llvm-cov measured them at 0% of
20 lines, putting the package under the 100% line threshold and failing the coverage gate.

Cover both arms of each entry point — expanded and reported — which takes lib.rs from
0% to 100%. The entry points are covered rather than excused: unlike the proc-macro
shim, they take `proc_macro2::TokenStream` and a test can call them. They carry no
snapshots, so they also run under miri.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
`anvil-mutants-diff` reported two surviving mutants, both replacing an entry point body
with `Ok(Default::default())`: `event` at lib.rs:29 and `derive_enrichment` at lib.rs:34.
Nothing killed them because the moved tests reach the logic through `internals::*` and
never call the crate's own entry points, so returning an empty `TokenStream` from either
went unnoticed.

Call both directly and assert on the expansion, which a `Default::default()` return fails,
plus the parse-error arm of `derive_enrichment`. This mirrors the `ohno_macros_impl`
entry-point tests added earlier in this branch for the same reason. No snapshots, so these
also run under miri.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The root `CHANGELOG.md` indexes every crate that ships a changelog, and
`observed_macros_impl` ships one. Registering `ohno_macros_impl` without it
left the claim in the PR description only half true.

`observed` and `observed_macros` are absent from this index on `main` even
though both carry a changelog; that predates this PR and is left alone.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings August 19, 2026 17:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 62 out of 162 changed files in this pull request and generated no new comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants