Skip to content

Replace allow(dead_code) with expect(dead_code) - #39527

Draft
antiguru wants to merge 1 commit into
mainfrom
expect-dead-code
Draft

antiguru wants to merge 1 commit into
mainfrom
expect-dead-code

Conversation

@antiguru

@antiguru antiguru commented Oct 4, 2026 •

Copy link
Copy Markdown
Member

An allow(dead_code) stays in place after the code it covers becomes used, and then hides dead code added later. expect(dead_code) warns once the code is used, so the attribute cannot outlive its reason. This converts all allow(dead_code) and allow(unused) attributes and adds a bin/lint check that rejects new ones.

Stale attributes are removed. Attributes on code that is dead only outside tests or without debug assertions are scoped with cfg_attr. CodecConcreteType now derives PartialEq unconditionally, since its field is read through Debug in error messages. Two sites keep allow behind an explicit // allow(allow-dead-code) opt-out: a macro whose expansions differ in what they use, and MigrationAction, whose used variants change with each catalog migration.

The rule is documented in doc/developer/style.md. Supersedes the fork PR #39525.

Posted by Claude Code.

🤖 Generated with Claude Code

An `allow(dead_code)` stays in place after the code it covers becomes
used, and then hides dead code added later. `expect(dead_code)` warns
once the code is used, so the attribute cannot outlive its reason.

Convert all `allow(dead_code)` and `allow(unused)` attributes to
`expect(dead_code)`. Remove attributes whose code is used, and scope
those that only apply to non-test or non-debug builds with `cfg_attr`.
Derive `PartialEq` on `CodecConcreteType` unconditionally, since its
field is read through `Debug` in error messages. Keep `allow` with an
explicit opt-out comment where `expect` cannot work: a macro whose
expansions differ in what they use, and `MigrationAction`, whose used
variants change with each catalog migration.

Add a `bin/lint` check that rejects `allow(dead_code)` and
`allow(unused)`, and document the rule in the style guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@antiguru
antiguru added this pull request to stack #39529 October 4, 2026 18:18
@antiguru antiguru changed the title expect dead code Replace allow(dead_code) with expect(dead_code) Oct 4, 2026

This branch has not been deployed

No deployments
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.

1 participant