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

Enforce irrefutability in Rust let bindings and parameters using gccrs

gccrs now diagnoses refutable patterns in non-optional let bindings and function parameters.

gccrs enforces the rule that let bindings (without an else clause) and function parameters must use irrefutable patterns. The compiler now issues diagnostics for refutable patterns in these contexts, deferring comprehensive checks to the PatternChecker after type information is available. This improves compile-time safety by preventing non-exhaustive pattern matches where they are not permitted.

In Details

The PatternChecker::visit in gccrs now includes diagnostics for refutable patterns used in function parameters and LetStmt bindings that lack an else clause. The ASTLoweringItem::visit is simplified to only error on bare literal patterns during lowering, with the full irrefutability check now performed post-type-checking. This relies on the is_refutable(BaseType&) function to determine pattern exhaustiveness.

For Context
gccrs
The GCC backend for the Rust programming language, enabling Rust code to be compiled by GCC.
irrefutable pattern
A pattern in Rust that is guaranteed to match any value of the given type. Examples include simple variable bindings (x) or struct/tuple patterns where all fields are bound.
refutable pattern
A pattern in Rust that may or may not match a given value. Examples include Some(x) for an Option, or patterns with guards.
let binding
The declaration of a variable using the let keyword in Rust.
function parameter
A variable declared in a function's signature that receives a value when the function is called.
pattern matching
A mechanism in Rust (and other languages) for destructuring data by comparing it against a series of patterns. It's used in match expressions, let bindings, and function parameters.
Filed Under: rustcompilerpattern matchingsafety