Hadithcore
Al-Adab Al-Mufrad, 507

Abu Hurayrah reported the Messenger of Allah (ﷺ) as saying, "if a thorn pricks a Muslim in this world and he hopes for the reward against it then Allah forgives him his sins on the day of Resurrection".

حَدَّثَنَا بِشْرٌ، قَالَ‏:‏ حَدَّثَنَا عَبْدُ اللهِ، قَالَ‏:‏ حَدَّثَنَا عُبَيْدُ اللهِ بْنُ عَبْدِ الرَّحْمَنِ بْنِ عَبْدِ اللهِ بْنِ مَوْهَبٍ قَالَ‏:‏ حَدَّثَنِي عَمِّي عُبَيْدُ اللهِ بْنُ عَبْدِ اللهِ بْنِ مَوْهَبٍ قَالَ‏:‏ سَمِعْتُ أَبَا هُرَيْرَةَ يَقُولُ‏:‏ قَالَ رَسُولُ اللهِ صلى الله عليه وسلم‏:‏ مَا مِنْ مُسْلِمٍ يُشَاكُ شَوْكَةً فِي الدُّنْيَا يَحْتَسِبُهَا، إِلاَّ قُصَّ بِهَا مِنْ خَطَايَاهُ يَوْمَ الْقِيَامَةِ‏.‏

References2 variants
In-Book Reference
Book 29, Hadith 17
English Reference
Book 29, Hadith 507