Anas said that the Prophet visited a young man who was dying and asked him how he was. He replied, “I am hoping in God, messenger of God, but I am afraid of my sins,” whereupon God's messenger said, “The two cannot come together in a man’s heart at such a time without God giving him what he hopes for and granting him security from what he fears.”
Tirmidhi and Ibn Majah transmitted it, Tirmidhi saying that this is a gharib tradition.