Summary
Every generated lexer/parser currently wraps the entire generated module and
its public re-export in blanket warning suppression:
#[allow(warnings, missing_docs, clippy::all, clippy::pedantic, clippy::nursery)]
#[rustfmt::skip]
mod __antlr4_rust_generated {
// generated scaffolding and embedded user-authored Rust
}
The header is emitted by
generated_module_header.
allow(warnings) solved the consumer problem reported in #29: generated code
must be drop-in under strict lint configurations. It also suppresses useful
compiler diagnostics from:
- embedded actions, predicates,
@members, and future supported named
sections;
- generator mistakes such as ignored
Result values;
- deprecated API use and future-compatibility warnings.
Narrow the suppression contract while preserving #29's drop-in behavior.
Why this matters
warnings is the lint group containing all warning-by-default rustc lints.
An inner allow(warnings) can override a consumer's outer deny(...) for code
inside the generated module, unless the consumer uses forbid.
For embedded Rust, the generated file is also the user's source file from
rustc's perspective. A body such as:
some_fallible_operation(); // Result is ignored
should remain visible under unused_must_use rather than being silently
accepted because the generator needed dead_code or naming allowances for its
own scaffolding.
The sdf-labs/antlr4 template uses a finite set of targeted lint allowances.
Its exact list should not be copied, but it demonstrates the preferable
ownership boundary.
Goal
Remove blanket allow(warnings) from generated output and replace it with the
smallest stable set of targeted allowances needed by generated scaffolding.
Possible approaches:
- inventory and allow only expected rustc lints such as generated naming,
dead-code, and unused generated imports/variables;
- attach allowances to generated items/macros rather than the whole module;
- isolate user-authored embedded bodies into scopes which do not inherit broad
generated-code allowances;
- use targeted
#[expect(...)] only where the emitted shape guarantees the
lint, provided this does not create version-sensitive unfulfilled
expectations.
Keep #[rustfmt::skip]; formatting stability is a separate requirement from
warning visibility.
Required investigation
- Compile the full generated fixture corpus under the exact CI command and
record every rustc/clippy lint which currently depends on the blanket allow.
- Separate unavoidable grammar-derived naming lints from renderer defects which
should be fixed instead of allowed.
- Check generated lexer/parser modules with and without listener/visitor,
embedded/template actions, attrs, hooks, unreachable rules, and empty
semantics.
- Verify downstream crates with
#![deny(warnings)],
#![deny(unused_must_use)], and #![deny(deprecated)].
Acceptance criteria
Related
Non-goals
- Making generated source satisfy every optional Clippy lint without any
allowances.
- Removing
rustfmt::skip.
- Emitting warnings for target-language bodies which are not Rust; those should
be rejected or handled by the semantic accountability issue instead.
Summary
Every generated lexer/parser currently wraps the entire generated module and
its public re-export in blanket warning suppression:
The header is emitted by
generated_module_header.allow(warnings)solved the consumer problem reported in #29: generated codemust be drop-in under strict lint configurations. It also suppresses useful
compiler diagnostics from:
@members, and future supported namedsections;
Resultvalues;Narrow the suppression contract while preserving #29's drop-in behavior.
Why this matters
warningsis the lint group containing all warning-by-default rustc lints.An inner
allow(warnings)can override a consumer's outerdeny(...)for codeinside the generated module, unless the consumer uses
forbid.For embedded Rust, the generated file is also the user's source file from
rustc's perspective. A body such as:
should remain visible under
unused_must_userather than being silentlyaccepted because the generator needed
dead_codeor naming allowances for itsown scaffolding.
The
sdf-labs/antlr4template uses a finite set of targeted lint allowances.Its exact list should not be copied, but it demonstrates the preferable
ownership boundary.
Goal
Remove blanket
allow(warnings)from generated output and replace it with thesmallest stable set of targeted allowances needed by generated scaffolding.
Possible approaches:
dead-code, and unused generated imports/variables;
generated-code allowances;
#[expect(...)]only where the emitted shape guarantees thelint, provided this does not create version-sensitive unfulfilled
expectations.
Keep
#[rustfmt::skip]; formatting stability is a separate requirement fromwarning visibility.
Required investigation
record every rustc/clippy lint which currently depends on the blanket allow.
should be fixed instead of allowed.
embedded/template actions, attrs, hooks, unreachable rules, and empty
semantics.
#![deny(warnings)],#![deny(unused_must_use)], and#![deny(deprecated)].Acceptance criteria
allow(warnings).cargo clippy --locked --workspace --all-targets --all-features -- -D warningsgate.
#[must_use]/Resultoutput in embeddeduser-authored Rust fails under
deny(unused_must_use).observable under
deny(deprecated).downstream wrapper modules or lint configuration.
snapshots remain intentional.
AGENTS.md; a lint-onlysource change must not bump it automatically.
Related
modules usable in strict downstream workspaces.
Non-goals
allowances.
rustfmt::skip.be rejected or handled by the semantic accountability issue instead.