Hmbown/CodeWhale · error

default hotbar slot fits in u8

Error message

default hotbar slot fits in u8

What it means

A compile-time-shaped invariant: default_hotbar_bindings() numbers slots 1..=DEFAULT_HOTBAR_ACTIONS.len(), and the expect asserts that count never exceeds u8's range. It fires only if someone adds more than 255 default hotbar actions — a code-change bug, not runtime input.

Source

Thrown at crates/config/src/lib.rs:1390

                "hotbar slot {slot} references unknown action '{action}'; keeping binding"
            ),
        }
    }
}

#[derive(Debug, Clone, PartialEq, Eq)]
pub struct HotbarConfigResolution {
    pub bindings: Vec<HotbarBinding>,
    pub warnings: Vec<HotbarConfigWarning>,
}

#[must_use]
pub fn default_hotbar_bindings() -> Vec<HotbarBinding> {
    DEFAULT_HOTBAR_ACTIONS
        .iter()
        .enumerate()
        .map(|(idx, action)| HotbarBinding {
            slot: u8::try_from(idx + 1).expect("default hotbar slot fits in u8"),
            action: (*action).to_string(),
            label: None,
        })
        .collect()
}

/// The default hotbar slots in on-disk (`[[hotbar]]`) form. Since #3807 an
/// absent `hotbar` key means "hidden", so `/hotbar on` persists these explicit
/// bindings rather than deleting the key. Kept in terms of
/// [`default_hotbar_bindings`] so `DEFAULT_HOTBAR_ACTIONS` stays the single
/// source of truth.
#[must_use]
pub fn default_hotbar_bindings_toml() -> Vec<HotbarBindingToml> {
    default_hotbar_bindings()
        .into_iter()
        .map(|binding| HotbarBindingToml {
            slot: binding.slot,
            action: binding.action,

View on GitHub (pinned to 0c42157ee5)

Solutions

  1. Keep DEFAULT_HOTBAR_ACTIONS at 255 entries or fewer
  2. Change HotbarBinding.slot to a wider integer type if the action list must grow
Defensive patterns

Strategy: type-guard

When it happens

Trigger: Thrown at crates/config/src/lib.rs:1390 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20). Data as JSON: /api/errors/dfbf23d560d88583. Report an issue: GitHub.