Skip to content

view: add #[diagnostic::on_unimplemented] hint to HasMessageView#161

Merged
iainmcgin merged 1 commit into
mainfrom
hasmessageview-diagnostic
May 29, 2026
Merged

view: add #[diagnostic::on_unimplemented] hint to HasMessageView#161
iainmcgin merged 1 commit into
mainfrom
hasmessageview-diagnostic

Conversation

@iainmcgin
Copy link
Copy Markdown
Collaborator

Summary

Adds a #[diagnostic::on_unimplemented] hint to buffa::HasMessageView, mirroring the existing ViewEncode diagnostic in the same module.

HasMessageView impls are emitted by codegen next to each message's view types (since 0.7.0). Downstream consumers bound on it in generated code — most prominently connect-rust's service stubs, where the unsatisfied bound surfaces inside the consumer's generated file at a call site they cannot annotate. With this change the error explains the cause and the fix instead of only naming the missing trait bound:

error[E0277]: `Simple` does not implement `HasMessageView` — its message-view family was not generated or is not enabled
  = note: the `HasMessageView` impl is emitted next to each message's view types: regenerate the crate that
          defines `Simple` with buffa 0.7.0 or newer and views enabled — `generate_views(true)` (on by default)
          in a buffa-build / buffa-codegen config, or `views=true` for protoc-gen-buffa
  = note: if the defining crate feature-gates its generated impls, enabling its views feature is enough — no
          regeneration needed

(Rendered output verified against a views-off generated type from buffa-test.)

Notes

  • #[diagnostic::on_unimplemented] stabilized in Rust 1.78; MSRV is 1.87, and ViewEncode already carries the same attribute form.
  • No test added: there is no compile-fail/UI test harness in the repo, and the attribute has no runtime behavior; the rendered output was verified manually as above.
  • CHANGELOG entry added under Unreleased → Changed.

When a bound on HasMessageView fails - typically in downstream generated
code such as connect-rust service stubs, where the user cannot annotate
the call site - the compiler error now explains the cause and the fix:
regenerate the defining crate with buffa 0.7.0 or newer and views
enabled (generate_views(true) in buffa-build/buffa-codegen, views=true
for protoc-gen-buffa), or enable the crate's views feature when the
generated impls are feature-gated. Mirrors the existing ViewEncode
diagnostic in the same module.
@github-actions
Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@iainmcgin iainmcgin marked this pull request as ready for review May 29, 2026 17:13
@iainmcgin iainmcgin requested a review from rpb-ant May 29, 2026 17:13
@iainmcgin iainmcgin merged commit 4482690 into main May 29, 2026
7 checks passed
@iainmcgin iainmcgin deleted the hasmessageview-diagnostic branch May 29, 2026 17:40
@github-actions github-actions Bot locked and limited conversation to collaborators May 29, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants