Your income is U.S.-source. That breaks Form 1116.
The Foreign Tax Credit offsets U.S. tax on foreign-source income. Social Security and a domestic pension are U.S.-source no matter where you sleep. So when Spain taxes your 401(k) distribution, there is no foreign-source income in the passive basket to hang the credit on.
The model on this page assumes that hatch is open wherever a treaty exists. The escape hatch is a treaty re-sourcing clause, claimed on a separate Form 1116 marked certain income re-sourced by treaty, with Form 8833 disclosure. Where there is no treaty — Panama, Colombia, Uruguay, Belize, Malaysia — that hatch does not exist.