diff --git a/src/missed_spans.rs b/src/missed_spans.rs index 64025550410..aa1d4679e9a 100644 --- a/src/missed_spans.rs +++ b/src/missed_spans.rs @@ -43,6 +43,10 @@ impl<'a> FmtVisitor<'a> { self.codemap.lookup_char_pos(end)); if start == end { + // Do nothing if this is the beginning of the file. + if start == BytePos(0) { + return; + } process_last_snippet(self, "", ""); return; } diff --git a/tests/target/no_new_line_beginning.rs b/tests/target/no_new_line_beginning.rs new file mode 100644 index 00000000000..f79c691f085 --- /dev/null +++ b/tests/target/no_new_line_beginning.rs @@ -0,0 +1,2 @@ +fn main() { +}