"A man among the Companions of the Prophet ﷺ died before Khamr had been made unlawful. So when Khamr was made unlawful, some men said: 'How about our companions who died while drinking Khamr?' So (the following) was revealed: Those who believe and do righteous good deeds, there is no sin on them for what the ate, if they have Taqwa and perform good (5:93)."
مَاتَ رِجَالٌ مِنْ أَصْحَابِ النَّبِيِّ ﷺ قَبْلَ أَنْ تُحَرَّمَ الْخَمْرُ فَلَمَّا حُرِّمَتِ الْخَمْرُ قَالَ رِجَالٌ كَيْفَ بِأَصْحَابِنَا وَقَدْ مَاتُوا يَشْرَبُونَ الْخَمْرَ فَنَزَلَتْ ( لَيْسَ عَلَى الَّذِينَ آمَنُوا وَعَمِلُوا الصَّالِحَاتِ جُنَاحٌ فِيمَا طَعِمُوا إِذَا مَا اتَّقَوْا وَآمَنُوا وَعَمِلُوا الصَّالِحَاتِ )