-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Wrong line numbers produces in rustc_span::SourceFile::lookup_file_pos* #84127
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
Comments
@rustbot label +A-code-coverage |
You're absolutely right that this doc comment is incomplete, though I would not say it "0-based" (valid values are always 1-based). But I should correct the comment. The source uses /// ... If the source_file is empty or the position is located before the
/// first line, a line number of `0` is returned.
|
There also |
Yes, thanks. The same applies in that function's comment as well. We should update both. |
pub struct Loc {
/// Information about the original source.
pub file: Lrc<SourceFile>,
/// The (1-based) line number.
pub line: usize,
/// The (0-based) column offset.
pub col: CharPos,
/// The (0-based) column offset when displayed.
pub col_display: usize,
} which will invalidate expectations in that struct. |
True (and again, thanks for recognizing these inconsistencies! They should be fixed.) But if you look at the implementation of So I guess the The alternative is to change all of these line variables and the struct field to an |
Yes, i forgot to check previous revisions, sorry. |
Just to clarify, |
@klensy - Is there a reason you've labeled this related to |
This is not a bug in code coverage. Code coverage works correctly, based on the current behavior of @rustbot label -A-code-coverage |
@richkadel, @klensy, is this still relevant, and if so did either of you want to propose a fix? |
Function comments noted, that they returns 1-based line number, but can actually return 0-based, #77080 @richkadel
rust/compiler/rustc_span/src/lib.rs
Lines 1515 to 1573 in c18c0ad
Perhaps this can be prevented via using different types for 0- and 1- based line numbers.
The text was updated successfully, but these errors were encountered: