Skip to content

fix(connectrpc-build): suppress unused_qualifications + impl_trait_redundant_captures in generated mod.rs#94

Merged
iainmcgin merged 2 commits intomainfrom
iain/codegen-allow-lints
May 7, 2026
Merged

fix(connectrpc-build): suppress unused_qualifications + impl_trait_redundant_captures in generated mod.rs#94
iainmcgin merged 2 commits intomainfrom
iain/codegen-allow-lints

Conversation

@iainmcgin
Copy link
Copy Markdown
Collaborator

Adds unused_qualifications and impl_trait_redundant_captures to the #[allow(...)] block connectrpc-build writes into the generated mod.rs package tree, and documents the related refining_impl_trait_internal lint.

Why

The 0.4.0 codegen output trips two rustc lints in workspaces that build with -D warnings:

  • impl_trait_redundant_captures: trait method RPITs carry a use<'a, Self> precise-capturing clause. It is required for edition-2021 consumers (RPIT-in-trait captures only 'static by default there) but redundant under edition 2024 (which captures all in-scope generics by default). Codegen targets both editions and cannot know the consumer's at write time, so the clause must stay — but it shouldn't warn.

  • unused_qualifications: buffa 0.5 codegen always references sibling types through the canonical pkg::__buffa::view::* path even when a shorter natural-path re-export exists, because the re-export can be shadowed by a same-named proto type. The qualification is intentional. (Suppressed redundantly here on top of fix(buffa-codegen): add unused_qualifications to ALLOW_LINTS buffa#102 for connectrpc-build consumers whose protoc-gen-buffa toolchain hasn't picked up that release yet.)

Both lints fire at locations under the generated pub mod <pkg> tree that connectrpc_build::Config::include_file() writes, so the right scope for the suppression is the same #[allow(...)] block that already carries dead_code, unused_imports, etc.

refining_impl_trait_internal — known limitation, no codegen-side fix

This release also documents (CHANGELOG only) that refining_impl_trait_internal (warn by default since rust 1.86, rust-lang/rust#121718) fires on every handler impl, because the generated trait declares ServiceResult<impl Encodable<Out> + …> while the handler returns ServiceResult<Out>. The refinement is intentional — it lets handlers return either an owned message, a borrowed view, or MaybeBorrowed<M, V> — and is benign for handler impls. There is no place in the generated module tree where #[allow(...)] could reach the consumer's handler impl. Consumers who deny warnings should set refining_impl_trait_internal = "allow" in [lints.rust] (or workspace lints) or #[allow(refining_impl_trait)] on each handler impl block.

Verification

  • cargo test -p connectrpc-build -p connectrpc-codegen --lib: 18 + 35 passed
  • cargo build -p eliza-example -p multiservice-example: clean
  • cargo clippy -p connectrpc-conformance -p eliza-example -- -D warnings: clean

Add `push: tags: ['v*']` to the publish-crates workflow so a release
tag triggers the crates.io publish automatically, matching the buffa
publish-crates workflow. The workflow_dispatch path stays for re-runs
and dry-run verification. On a tag push `inputs.dry_run` is undefined
(falsy), so the run is always a real publish; the `crates-io`
environment's branch policy restricts which refs can run in it.
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 7, 2026

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

…dundant_captures in generated mod.rs

The 0.4.0 codegen output trips two rustc lints in workspaces that build
with -D warnings:

- impl_trait_redundant_captures: the use<'a, Self> precise-capturing
  clause on trait method RPITs is required for edition-2021 consumers
  (which capture only 'static by default) but redundant under edition
  2024. Codegen targets both editions and cannot know the consumer's at
  write time, so the clause must stay.
- unused_qualifications: buffa 0.5 codegen always references sibling
  types through the canonical pkg::__buffa::view::* path even when a
  shorter natural-path re-export exists, because the re-export can be
  shadowed by a same-named proto type. The qualification is intentional.

Both lints fire at locations under the generated `pub mod <pkg>` tree
that connectrpc-build's include_file() writes, so the right scope for
the suppression is the same #[allow(...)] block that already carries
dead_code, unused_imports, etc.

This patch release also documents refining_impl_trait_internal in the
CHANGELOG: there is no codegen-side workaround for it (the warning
fires on the consumer's handler `impl`, outside the generated tree),
so consumers building with -D warnings must allow it themselves.
@iainmcgin iainmcgin force-pushed the iain/codegen-allow-lints branch from bd3e488 to 86de223 Compare May 7, 2026 15:39
@iainmcgin iainmcgin marked this pull request as ready for review May 7, 2026 15:43
@iainmcgin iainmcgin requested a review from rpb-ant May 7, 2026 15:43
@iainmcgin iainmcgin merged commit a9a43e7 into main May 7, 2026
12 checks passed
@github-actions github-actions Bot locked and limited conversation to collaborators May 7, 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