Skip to content

Commit a1edf91

Browse files
committed
Fix bug in detecting trailing comments when at beginning-of-file.
1 parent 700c525 commit a1edf91

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/comp/front/lexer.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,9 +891,10 @@ fn gather_comments_and_literals(session sess, str path)
891891
auto rdr = new_reader(sess, srdr, codemap::new_filemap(path, 0u), itr);
892892
let vec[cmnt] comments = [];
893893
let vec[lit] literals = [];
894+
let bool first_read = true;
894895
while (!rdr.is_eof()) {
895896
while (true) {
896-
auto code_to_the_left = true;
897+
auto code_to_the_left = !first_read;
897898
consume_non_eol_whitespace(rdr);
898899
if (rdr.curr() == '\n') {
899900
code_to_the_left = false;
@@ -909,6 +910,7 @@ fn gather_comments_and_literals(session sess, str path)
909910
vec::push[lit](literals, rec(lit=rdr.get_mark_str(),
910911
pos=rdr.get_mark_chpos()));
911912
}
913+
first_read = false;
912914
}
913915
ret rec(cmnts=comments, lits=literals);
914916
}

0 commit comments

Comments
 (0)