Qadi Shurayh (may Allah have mercy on him) said: When something is pledged for a debt and the pledged item then perishes, it goes in exchange for that debt.