The Book of the Prohibited actions
Riyad as-Salihin #897
كتاب الأمور المنهي عنها
وعن جُندب بن عبد الله رضي الله عنه قال: قال رسول الله صلى الله عليه وسلم: «قال رجل: والله لا يغفر الله لفلان، فقال الله عز وجل: من ذا الذي يتألى علي أن لا أغفر لفلان! فإني قد غفرت له، وأحبطت عملك» ((رواه مسلم)).
Jundub bin 'Abdullah (May Allah be pleased with him) reported:
The Messenger of Allah (ﷺ) said, “Once someone said: 'By Allah! Allah will not forgive such and such (a person).' Thereupon Allah, the Exalted and the Glorious, said: 'Who is he who takes an oath in My Name that I will not grant pardon to so-and-so? I have granted pardon to so-and-so and rendered your good deeds fruitless.”'.
وعن جُندب بن عبد الله رضي الله عنه قال: قال رسول الله صلى الله عليه وسلم : "قال رجل: والله لا يغفر الله لفلان، فقال الله عز وجل: من ذا الذي يتألى علي أن لا أغفر لفلان! فإني قد غفرت له، وأحبطت عملك" ((رواه مسلم)).
The Messenger of Allah (ﷺ) said, "Once someone said: 'By Allah! Allah will not forgive such and such (a person).' Thereupon Allah, the Exalted and the Glorious, said: 'Who is he who takes an oath in My Name that I will not grant pardon to so-and-so? I have granted pardon to so-and-so and rendered your good deeds fruitless."'.
— Riyad as-Salihin, Hadith 897