Long numeric literal written without digit separators

ID

rust.maintainability.unreadable_literal

Severity

info

Remediation Complexity

trivial

Remediation Risk

low

Remediation Effort

low

Resource

Readability

Language

Rust

Description

Detects a numeric literal long enough to be hard to read that does not use the _ digit separator: six or more decimal digits, or nine or more digits in a hexadecimal, binary or octal literal.

Rationale

Rust allows _ anywhere inside a numeric literal precisely because an unbroken run of digits cannot be checked by eye. A reviewer cannot tell 1000000 from 10000000, so an off-by-one-order-of-magnitude constant - a timeout, a byte limit, a bit mask - passes review unnoticed and only shows up as a production incident.

The following code illustrates the pattern detected by this rule:

// FLAGGED: Long numeric literal written without digit separators
pub const MAX_BYTES: usize = 100000;

Remediation

Group the digits with _: thousands for decimal values (1_000_000), four-digit groups for hexadecimal and binary masks (0xDEAD_BEEF, 0b1010_1010). The separators are ignored by the compiler, so the value is unchanged.

Configuration

This detector does not need any configuration.

© 2026 Xygeni. All rights reserved