"Some people among the Companions of the Prophet ﷺ died while they had been drinking Khamr. So when it was revealed that it was unlawful, some people among the Companions of the Messenger of Allah ﷺ said: 'How about our companions who died while they were drinking it?' So (the following) Ayah was revealed: Those who believe and do righteous good deeds, there is no sin on them for what they ate (5:93)."
الْبَرَاءُ بْنُ عَازِبٍ مَاتَ نَاسٌ مِنْ أَصْحَابِ النَّبِيِّ ﷺ وَهُمْ يَشْرَبُونَ الْخَمْرَ فَلَمَّا نَزَلَ تَحْرِيمُهَا قَالَ نَاسٌ مِنْ أَصْحَابِ النَّبِيِّ ﷺ فَكَيْفَ بِأَصْحَابِنَا الَّذِينَ مَاتُوا وَهُمْ يَشْرَبُونَهَا فَنَزَلَتْْ ( لَيْسَ عَلَى الَّذِينَ آمَنُوا وَعَمِلُوا الصَّالِحَاتِ ) الآيَةَ