zed-industries/zed · error
checked for type drag state type above
Error message
checked for type drag state type above
What it means
In Div's drop-listener dispatch, the active drag is downcast to the drag state type; the comment says the type was checked above (the listener was only registered for matching drags), so the expect firing means the registration-side type check and the dispatch-side downcast disagree — an internal invariant break.
Source
Thrown at crates/gpui/src/elements/div.rs:2906
}
}
let drag_cursor_style = self.base_style.as_ref().mouse_cursor;
let mut drag_listener = mem::take(&mut self.drag_listener);
let drop_listeners = mem::take(&mut self.drop_listeners);
let click_listeners = mem::take(&mut self.click_listeners);
let aux_click_listeners = mem::take(&mut self.aux_click_listeners);
let can_drop_predicate = mem::take(&mut self.can_drop_predicate);
if !drop_listeners.is_empty() {
let hitbox = hitbox.clone();
window.on_mouse_event({
move |_: &MouseUpEvent, phase, window, cx| {
if let Some(drag) = &cx.active_drag
&& phase == DispatchPhase::Bubble
&& hitbox.is_hovered(window)
{
let drag_state_type = drag.value.as_ref().type_id();
for (drop_state_type, listener) in &drop_listeners {
if *drop_state_type == drag_state_type {
let drag = cx
.active_drag
.take()
.expect("checked for type drag state type above");
let mut can_drop = true;
if let Some(predicate) = &can_drop_predicate {
can_drop = predicate(drag.value.as_ref(), window, cx);
}
if can_drop {
listener(drag.value.as_ref(), window, cx);
window.refresh();
cx.stop_propagation();
}View on GitHub (pinned to 9d272b0363)
Solutions
- Compare the type check where the drop listener is registered with the downcast at dispatch
- Ensure can_drop_predicate/listener registration filters by the same drag type T
- Treat as a GPUI bug; reproduce with a minimal drag-and-drop of the mismatched state type
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/gpui/src/elements/div.rs:2788 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/d4cf502e0c473282.
Report an issue: GitHub.