fix panic when dense store rename src==dest

This commit is contained in:
Adam Gausmann 2026-10-02 00:17:41 -05:00
parent a0948315be
commit af421f97dd

View file

@ -327,6 +327,7 @@ impl Sandbox {
fn remove_net(&mut self, net_id: NetId) -> Option<NetInfo> { fn remove_net(&mut self, net_id: NetId) -> Option<NetInfo> {
if let Some((net, rename)) = self.nets.remove(net_id.0) { if let Some((net, rename)) = self.nets.remove(net_id.0) {
if rename.src != rename.dest {
// Rename all the references to the net that was moved into this position. // Rename all the references to the net that was moved into this position.
let renamed = self.nets.get(rename.dest).unwrap(); let renamed = self.nets.get(rename.dest).unwrap();
for wire_id in &renamed.wires { for wire_id in &renamed.wires {
@ -336,6 +337,7 @@ impl Sandbox {
for peg_id in &renamed.pegs.clone() { for peg_id in &renamed.pegs.clone() {
self.get_peg_mut(peg_id).unwrap().net_id = NetId(rename.dest); self.get_peg_mut(peg_id).unwrap().net_id = NetId(rename.dest);
} }
}
// Perform the same swap-remove in net_states: // Perform the same swap-remove in net_states:
self.net_states.swap_remove(rename.dest.into_raw()); self.net_states.swap_remove(rename.dest.into_raw());