When the Messenger of Allah ﷺ wished to sleep while in a state of major ritual impurity, he would perform ablution as he did for prayer before going to sleep.
أخبرنا قتيبة بن سعيد قال حدثنا الليث عن ابن شهاب عن أبي سلمة بن عبد الرحمن
إن رسول الله ﷺ كان إذا أراد أن ينام وهو جنب توضأ وضوءه للصلاة قبل أن ينام
Muslim narrated it in his chapter on menstruation, in the section on the permissibility of a person in a state of major impurity sleeping and the recommendation of wudu for him, etc., hadith no. 305, from Qutayba, with this wording. See also the two preceding hadiths.