diff --git a/compiler/rustc_span/src/lib.rs b/compiler/rustc_span/src/lib.rs index 5232c8d7006bd..45b0e0c2dd1f8 100644 --- a/compiler/rustc_span/src/lib.rs +++ b/compiler/rustc_span/src/lib.rs @@ -1318,17 +1318,20 @@ impl Decodable for SourceFile { let mut line_start: BytePos = Decodable::decode(d); lines.push(line_start); - for _ in 1..num_lines { - let diff = match bytes_per_diff { - 1 => d.read_u8() as u32, - 2 => d.read_u16() as u32, - 4 => d.read_u32(), - _ => unreachable!(), - }; - - line_start = line_start + BytePos(diff); - - lines.push(line_start); + match bytes_per_diff { + 1 => lines.extend((1..num_lines).map(|_| { + line_start = line_start + BytePos(d.read_u8() as u32); + line_start + })), + 2 => lines.extend((1..num_lines).map(|_| { + line_start = line_start + BytePos(d.read_u16() as u32); + line_start + })), + 4 => lines.extend((1..num_lines).map(|_| { + line_start = line_start + BytePos(d.read_u32()); + line_start + })), + _ => unreachable!(), } }