leptos-rs/leptos · error
List of slots must not be empty
Error message
List of slots must not be empty
What it means
slot_to_tokens in leptos_macro collects component slot properties into a map and then drains it, taking .last() of each slot's values to get a span. If a slot key exists in the map with an empty values vec, the expect panics with 'List of slots must not be empty'. This is a compile-time panic inside the view! macro expansion.
Source
Thrown at leptos_macro/src/view/slot_helper.rs:171
}
} else {
quote_spanned! {children.span()=>
.children({
#(#clonables)*
::leptos::children::ToChildren::to_children(move || #children #view_marker)
})
}
}
} else {
quote! {}
}
};
let slots = slots.drain().map(|(slot, mut values)| {
let span = values
.last()
.expect("List of slots must not be empty")
.span();
let slot = Ident::new(&slot, span);
let value = if values.len() > 1 {
quote! {
::std::vec![
#(#values)*
]
}
} else {
values.remove(0)
};
quote! { .#slot(#value) }
});
let build = quote_spanned! {node.name().span()=>
.build()
};View on GitHub (pinned to 32d20f6c9d)
Solutions
- Ensure each slot passed to the component actually contains content, e.g. <SlotName slot:A>{...}</SlotName> with children or attributes.
- Update leptos_macro/leptos to matching versions (cargo update) — empty slot values may be a fixed macro bug.
- Reduce the view! usage to a minimal repro and report it upstream if the slot is non-empty but still triggers the panic.
Example fix
// before <Parent slot:header /> // empty slot // after <Parent slot:header><h1>"Title"</h1></Parent>
Defensive patterns
Strategy: validation
Validate before calling
// check all slot properties have content before macro expansion
fn slot_has_content(inner: &str) -> bool { !inner.trim().is_empty() } Prevention
- Give every slot: property children/attributes; keep leptos_macro versions aligned
When it happens
Trigger: A slot entry is inserted into the slots map with no accumulated values — an internal invariant violation when processing component children with #[slot] attributes; typically triggered by malformed or duplicated slot handling in the view! macro (e.g. a slot property with zero children tokens).
Common situations: Using view! with a custom component taking #[slot] parameters where slot markup is empty or the macro version has a bug collecting slot values; mixing macro versions between leptos and leptos_macro.
Related errors
- element needs to have a name
- keyword argument repeated: `encoding`
- keyword argument repeated: `endpoint`
- `encoding` and `input` should not both be specified
- keyword argument repeated: `input`
AI-assisted analysis of leptos-rs/leptos@32d20f6c9d (2026-09-01).
Data as JSON: /api/errors/7d2fcd3ea127a65b.
Report an issue: GitHub.