Repository: servo/servo
File: components/script/dom/document_event_handler.rs (Rust)

Code before:
                // original target from touchstart
                let original_target = active[index].Target();

                let changed_touch = Touch::new(
                    window,
                    identifier,
                    &original_target,
                    client_x,
                    client_y,
                    client_x,
                    client_y,
                    page_x,
                    page_y,
                    can_gc,
                );

                // Update or remove the stored touch
                match event.event_type {
                    TouchEventType::Move => {
                        active[index] = Dom::from_ref(&*changed_touch);
                    },
                    TouchEventType::Up | TouchEventType::Cancel => {
                        active.swap_remove(index);
                        self.remove_pointer_id_for_touch(identifier);
                    },
                    TouchEventType::Down => unreachable!(),
                }
                (original_target, changed_touch)
            },
        };

        let touches = {
            let active = self.active_touch_points.borrow();
            TouchList::new(window, active.r(), can_gc)
        };

        let target_touches = {
            let active = self.active_touch_points.borrow();
            rooted_vec!(let mut filtered);
            filtered.extend(
                active
                    .iter()
                    .filter(|t| t.Target() == touch_dispatch_target)
                    .cloned(),
            );
            TouchList::new(window, filtered.r(), can_gc)
        };

        let changed_touches = TouchList::new(window, from_ref(&&*changed_touch), can_gc);

        let event_name = match event.event_type {

Review comment (suggestion):
```suggestion
                    TouchEventType::Down => unreachable!("Should have been handled above"),
```

Code after:

                let touch_with_touchstart_target = Touch::new(
                    window,
                    identifier,
                    &original_target,
                    client_x,
                    client_y,
                    client_x,
                    client_y,
                    page_x,
                    page_y,
                    can_gc,
                );

                // Update or remove the stored touch
                match event.event_type {
                    TouchEventType::Move => {
                        active_touch_points[index] = Dom::from_ref(&*touch_with_touchstart_target);
                    },
                    TouchEventType::Up | TouchEventType::Cancel => {
                        active_touch_points.swap_remove(index);
                        self.remove_pointer_id_for_touch(identifier);
                    },
                    TouchEventType::Down => unreachable!("Should have been handled above"),
                }
                (original_target, touch_with_touchstart_target)
            },
        };

        rooted_vec!(let mut target_touches);
        target_touches.extend(
            self.active_touch_points
                .borrow()
                .iter()
                .filter(|t| t.Target() == touch_dispatch_target)
                .cloned(),
        );

        let event_name = match event.event_type {
            TouchEventType::Down => "touchstart",
            TouchEventType::Move => "touchmove",
            TouchEventType::Up => "touchend",
            TouchEventType::Cancel => "touchcancel",
        };

        let touch_event = TouchEvent::new(
            window,
            DOMString::from(event_name),
            EventBubbles::Bubbles,
            EventCancelable::from(event.is_cancelable()),
            EventComposed::Composed,