Jundab reported,

The Messenger of Allah ﷺ related that a man said, "By Allah, Allah will not forgive so-and-so."Allah the Exalted then said, "Who is this who swears by Me that I will not forgive so-and-so? Indeed, I have forgiven so-and-so and rendered your deeds void," or as he said.

Azami 14615

Sahih

عن جندب

أن رسول الله ﷺ حدث أن رجلا قال: والله لا يغفر الله لفلان، وإن الله تعالى قال: من ذا الذي يتألى علي أن لا أغفر لفلان، فإني قد غفرت لفلان، وأحبطت عملك أو كما قال.

الأعظمي 14615صحيح
Contents
Reference
Commentary
Ayat
Collection
Jami al-Kamil
Book
Superior moral conduct
Chapter
Etiquette of speech, words, and correspondence
Section
Discouraging saying "Allah will not forgive so-and-so"
Numbering
Jami al-Kamil 14615 (2nd edition)
Azami 14615