-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change treatment of zero-length filemaps #26816
Conversation
r? @pnkfelix (rust_highfive has picked a reviewer for you, use r? to override) |
|
||
if parser.token == token::Eof && parser.span == codemap::DUMMY_SP { | ||
parser.span = codemap::mk_sp(end_pos, end_pos); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this redundant? The Eof token should never be associated with a dummy span, given the change to advance_token().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This still holds sometimes where the file is empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean, the condition can hold in the case where codemap::DUMMY_SP is legitimately the end of the first file? In that case, the code still doesn't do anything, because the new position is still equal to codemap::DUMMY_SP.
@pnkfelix review ping |
@nrc looks good to me r=me when you are done addressing comments |
So if a filemap's last byte is at position n in the codemap, then n+1 will not refer to any filemap, and the next filemap will begin an n+2. This is useful for empty files, it means that every file (even empty ones) has a byte in the codemap. Closes rust-lang#23301, rust-lang#26504
This basically only affects modules which are empty (or only contain comments). Closes rust-lang#26755
📌 Commit f47d20a has been approved by |
See commits for details