When the wider context is considered, I think we are safe to see Romans 4:5 as saying, "But to him who doesn't work [with a mindset as if to try to earn salvation], but [instead] believes in him who justifies the ungodly, his faith is accounted for righteousness."
For if that were not true then...