refactor(hm-plugin-protocol): Mark the wire-protocol BuildEvent enum #[non_exhaustive]#123
Merged
markovejnovic merged 2 commits intoJun 10, 2026
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The smell
BuildEventincrates/hm-plugin-protocol/src/events.rsis the central wire event type for the build event stream. It is a plain, exhaustivepub enum, matched exhaustively inhm-render(progress.rs,human.rs) andhm-exec. The protocol is explicitly designed to grow — several variants' doc comments already describe them as "replacing ad-hoc log lines," and more event kinds are expected over time.Because the enum is exhaustive, adding any new variant is a breaking change for every downstream
matchand a semver-major bump for the crate.The change
Add
#[non_exhaustive]toenum BuildEvent. This is a single-attribute change in this crate. Downstreammatcharms overBuildEventwill then need a_ => {}wildcard, after which new variants can be added without breaking external callers.Type-safety pattern
This applies the
#[non_exhaustive]pattern used bydieselandripgrep(and the standard library's own error/event enums) for public enums that are expected to grow — error kinds, event types, message kinds. It converts "adding one variant is a major break for every matcher" into a non-breaking change, while the compiler still enforces exhaustiveness for matches inside this crate.BuildEventis the prototypical growing event stream.Validation
Only
cargo check -p hm-plugin-protocolwas run locally (passes). The full build and TS build were intentionally not run. Full CI runs on this PR.This is a draft pending review. The change is behavior-preserving (an attribute only); it does not alter serialization or runtime behavior. Downstream crates in this same workspace already match exhaustively, so CI will confirm whether any in-workspace matcher needs a wildcard arm added (a non-
#[non_exhaustive]enum allows in-crate exhaustive matches, but#[non_exhaustive]only forces wildcards for out-of-crate matchers — so in-workspace matches should be unaffected).