Why is this an issue?

Using repr(isize/usize) for C-like enumerations with values that don’t fit into an i32 can lead to truncated variant values on 32-bit architectures, potentially causing unexpected behavior.

Code examples

Noncompliant code example

#[repr(usize)]
enum NonPortable {
    X = 0x1_0000_0000, // Noncompliant
    Y = 0,
}

Compliant solution

#[repr(u64)]
enum Portable {
    X = 0x1_0000_0000, // Compliant
    Y = 0,
}

Resources

Documentation