@@ -275,6 +275,28 @@ fn diff_keyed_children(
275275 new: &[Node],
276276 cached_roots: &mut FxHashSet<CacheId>,
277277) {
278+ if cfg!(debug_assertions) {
279+ let mut keys = FxHashSet::default();
280+ let mut assert_unique_keys = |children: &[Node]| {
281+ keys.clear();
282+ for child in children {
283+ let key = child.key();
284+ debug_assert!(
285+ key.is_some(),
286+ "if any sibling is keyed, all siblings must be keyed"
287+ );
288+ keys.insert(key);
289+ }
290+ debug_assert_eq!(
291+ children.len(),
292+ keys.len(),
293+ "keyed siblings must each have a unique key"
294+ );
295+ };
296+ assert_unique_keys(old);
297+ assert_unique_keys(new);
298+ }
299+
278300 // First up, we diff all the nodes with the same key at the beginning of the
279301 // children.
280302 //