diff --git a/src/missed_spans.rs b/src/missed_spans.rs index aa1d4679e9a..33d096c3ba0 100644 --- a/src/missed_spans.rs +++ b/src/missed_spans.rs @@ -44,7 +44,7 @@ impl<'a> FmtVisitor<'a> { if start == end { // Do nothing if this is the beginning of the file. - if start == BytePos(0) { + if start == self.codemap.lookup_char_pos(start).file.start_pos { return; } process_last_snippet(self, "", ""); diff --git a/tests/source/mod-2.rs b/tests/source/mod-2.rs index 75b560ce93f..c4a148a616e 100644 --- a/tests/source/mod-2.rs +++ b/tests/source/mod-2.rs @@ -1,3 +1,4 @@ // Some nested mods mod nestedmod; +mod no_new_line_beginning; diff --git a/tests/source/no_new_line_beginning.rs b/tests/source/no_new_line_beginning.rs new file mode 100644 index 00000000000..f79c691f085 --- /dev/null +++ b/tests/source/no_new_line_beginning.rs @@ -0,0 +1,2 @@ +fn main() { +} diff --git a/tests/target/mod-2.rs b/tests/target/mod-2.rs index 75b560ce93f..c4a148a616e 100644 --- a/tests/target/mod-2.rs +++ b/tests/target/mod-2.rs @@ -1,3 +1,4 @@ // Some nested mods mod nestedmod; +mod no_new_line_beginning;