You go to sleep, giving the Pokemon who used rest the sleep status. When it wakes up, it gets poisoned again.