RS.CLIPPY.ZERO_PREFIXED_LITERAL

Integer literals starting with `0`

This checker is a Clippy lint created by The Rust Project Contributors. The documentation shown here is a copy of the original documentation for: zero_prefixed_literal. Copyright ©2025 The Rust Team. All rights reserved.

What it does

Warns if an integral constant literal starts with 0.

Why is this bad?

In some languages (including the infamous C language and most of its family), this marks an octal constant. In Rust however, this is a decimal constant. This could be confusing for both the writer and a reader of the constant.

Example

In Rust:

fn main() {
    let a = 0123;
    println!("{}", a);
}

prints 123, while in C:

#include <stdio.h>

int main() {
    int a = 0123;
    printf("%d\
", a);
}

prints 83 (as 83 == 0o123 while 123 == 0o173).