TUESDAY, NOVEMBER 18, 2025
gccrs
Refactor dead code linting in gccrs
gccrs's dead code detection is refactored, moving checks for unused static and const items.
The dead code linting in gccrs has been reorganized. Checks for unused static items and unused const items are now handled by the ScanDeadcode visitor. The UnusedChecker retains only the visibility and naming lints for these items, consolidating dead code analysis.
In Details
In gccrs, the ScanDeadcode visitor now includes visit(HIR::ConstantItem) and visit(HIR::StaticItem) methods to identify unused items. Concurrently, UnusedChecker::visit for HIR::ConstantItem and HIR::StaticItem is modified to remove the unused-item checks, retaining only visibility and naming lints. This change centralizes dead code analysis within the ScanDeadcode pass.
For Context
- gccrs
- The GCC backend for the Rust programming language, enabling Rust code to be compiled by GCC.
- dead code
- Code that is unreachable or never executed during program execution. Compilers often identify and remove dead code to optimize program size and performance.
- lint
- A static code analysis tool that flags potential programming errors, stylistic errors, and suspicious constructs. In GCC, these are often referred to as 'warnings' or 'diagnostics'.
- static item
- A variable or constant associated with a type or module rather than an instance of a type, existing for the duration of the program.
- const item
- A compile-time evaluated constant value in Rust.
- HIR
- High-level Intermediate Representation. A representation of the code between the parser's abstract syntax tree (AST) and the lower-level intermediate representations used for optimization and code generation.