كتاب الإيمان
1  
The Book of Faith
(55)
Chapter: Clarifying the ruling of the action of an unbeliever if he accepts Islam after it
(55)
باب بَيَانِ حُكْمِ عَمَلِ الْكَافِرِ إِذَا أَسْلَمَ بَعْدَهُ ‏‏
Sahih Muslim 123 c

It is narrate on the authority of Hakim b. Hizam:

I said: Messenger of Allah, I did so some of the deeds in the state of ignorance. (One of the transmitters Hisham b. Urwa explained them as acts of piety. Upon this the Messenger, of Allah remarked: You have embraced Islam with all the previous acts of virtue. I said: By God, I would leave nothing undone in Islam the like of which I did in the state of ignorance.
حَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، وَعَبْدُ بْنُ حُمَيْدٍ، قَالاَ أَخْبَرَنَا عَبْدُ الرَّزَّاقِ، أَخْبَرَنَا مَعْمَرٌ، عَنِ الزُّهْرِيِّ، بِهَذَا الإِسْنَادِ ح وَحَدَّثَنَا إِسْحَاقُ بْنُ إِبْرَاهِيمَ، أَخْبَرَنَا أَبُو مُعَاوِيَةَ، حَدَّثَنَا هِشَامُ بْنُ عُرْوَةَ، عَنْ أَبِيهِ، عَنْ حَكِيمِ بْنِ حِزَامٍ، قَالَ قُلْتُ يَا رَسُولَ اللَّهِ أَشْيَاءَ كُنْتُ أَفْعَلُهَا فِي الْجَاهِلِيَّةِ - قَالَ هِشَامٌ يَعْنِي أَتَبَرَّرُ بِهَا - فَقَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ أَسْلَمْتَ عَلَى مَا أَسْلَفْتَ لَكَ مِنَ الْخَيْرِ ‏"‏ ‏.‏ قُلْتُ فَوَاللَّهِ لاَ أَدَعُ شَيْئًا صَنَعْتُهُ فِي الْجَاهِلِيَّةِ إِلاَّ فَعَلْتُ فِي الإِسْلاَمِ مِثْلَهُ ‏.‏
Reference : Sahih Muslim 123c
In-book reference : Book 1, Hadith 232
USC-MSA web (English) reference : Book 1, Hadith 224
  (deprecated numbering scheme)