diff --git a/cranelift/codegen/src/machinst/buffer.rs b/cranelift/codegen/src/machinst/buffer.rs index 6a5c06c04e4d..03debd945468 100644 --- a/cranelift/codegen/src/machinst/buffer.rs +++ b/cranelift/codegen/src/machinst/buffer.rs @@ -680,10 +680,14 @@ impl MachBuffer { // (end of buffer) self.data.truncate(b.start as usize); self.fixup_records.truncate(b.fixup); - while let Some(last_srcloc) = self.srclocs.last() { + while let Some(mut last_srcloc) = self.srclocs.last_mut() { if last_srcloc.end <= b.start { break; } + if last_srcloc.start < b.start { + last_srcloc.end = b.start; + break; + } self.srclocs.pop(); } // State: