GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gccrs

gccrs: Add unused unsafe lint

gccrs now warns about 'unsafe' blocks that don't perform operations requiring 'unsafe'.

A new lint has been added to gccrs to detect and warn about ‘unsafe’ blocks that do not contain any operations necessitating an unsafe context. The unsafe checker now tracks which ‘unsafe’ blocks are actually utilized by such operations, flagging any that are not. This feature, gated by -frust-unused-check-2.0, aims to improve code quality by identifying potentially unnecessary or dead ‘unsafe’ code.

In Details

The gccrs frontend introduces an UnsafeChecker pass that annotates 'unsafe' blocks based on their usage. New methods like mark_unsafe_used and tracked state used_unsafe_blocks within UnsafeChecker differentiate between 'unsafe' blocks that contain operations requiring elevated privileges (e.g., check_static_mut, check_extern_call) and those that do not. The visit method of UnsafeChecker orchestrates this, emitting a warning for unused 'unsafe' blocks when the -frust-unused-check-2.0 flag is enabled.

For Context
unsafe
A keyword in Rust that denotes a block of code where operations that bypass certain safety guarantees are permitted, such as dereferencing raw pointers or calling external C functions.
lint
A static code analysis tool that flags programming errors, potential bugs, stylistic errors, and suspicious constructs. In Rust, lints are used to enforce code quality and best practices.
unsafe context
The environment created by the unsafe keyword in Rust, allowing operations that the compiler cannot guarantee the safety of. These operations typically involve low-level memory manipulation or interaction with foreign code.
-frust-unused-check-2.0
A compiler flag for gccrs that enables a specific check related to unused unsafe blocks, likely a development or experimental feature being tested.
Filed Under: gccrslintunsaferustsecurity