Whenever the Messenger of Allah ﷺ was in a state of major ritual impurity and wished to sleep, he would perform ablution as he did for prayer before sleeping. He used to say, "Whoever wishes to sleep while in a state of major ritual impurity should perform ablution as he does for prayer."
قال حدثنا قتيبة قال حدثنا ابن لهيعة عن أبي الأسود عن عروة
كان رسول الله ﷺ إذا كان جنبا وأراد أن ينام وهو جنب توضأ وضوءه للصلاة قبل أن ينام وكان يقول من أراد أن ينام وهو جنب فليتوضأ وضوءه للصلاة