Make HashMap::take not corrupt the map. Fixes #19292