CARDIAC › rust-cardiac › Message codes › RCE0009
RCE0009error
A constant past what a card holds.
error[RCE0009]: constant out of range: {v} is past what a card holds ({lo} to {hi}): a literal that size, or arithmetic rustc worked out to it at compile time, would overflow a card
error[RCE0009]: constant out of range: i16::{name} ({v}) is past what a card holds (-999 to 999): no i16 on a card reaches it, so code that uses it as a value (a saturating method, say) can't be compiled
error[RCE0009]: constant out of range: {v} as {to} is past what a card holds, in {src}
error[RCE0009]: enum {e}: {variant} is {v}, past what a card holds (-999 to 999)
error[RCE0009]: static {name}: {v} is past what a card holds (-999 to 999)
error[RCE0009]: constant out of range: DAT {x} is past what a card holds
A number in the program that no card can hold: past -999 to 999.
A cell holds a sign and three digits. A literal like 1010, an enum variant numbered past 999, a static of one, or arithmetic rustc works out at compile time to such a number (101 * 10, even in a branch no run takes) has nowhere to go. It is Rust's own rule for a value that can't fit, for a card instead of an i16: rustc refuses 30000 * 2 in an i16 and i16::MAX + 1 in a const.
i16::MAX (32767) and i16::MIN are such numbers too. Methods that use them as values, such as saturating_add, which stops at 32767, can't be compiled.
Keep constants on a card. Compute what may pass one at run time, where the overflow check sees it.
// refused: 1200 is past a card
const LIMIT: i16 = 1200;
// compiles
const LIMIT: i16 = 999;
In a terminal: cargo cardiac help RCE0009.