Villagers sleeping in a bed are sucked into a minecart that comes beside them, where they remain lying down.
Steps to reproduce:
- Disable the daylight cycle and set the time to night.
- Place a bed.
- Spawn a villager beside the bed and wait for it to lie on the bed.
- Place rails beside the bed.
- Place a minecart beside the bed.
The villager moves into the minecart and remains in a sleeping position.
The villager remains in the bed. (At least that's what happens when you try this with a boat instead of a minecart.)