AnnotationColumn struct to fix hard tab column numbers in errors#109548
AnnotationColumn struct to fix hard tab column numbers in errors#109548bors merged 1 commit intorust-lang:masterfrom
Conversation
|
(rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
Why is the right number reported in @rustbot author |
|
There are multiple places in the code where error line/column references are generated: So-called "primary" messages are generated here (emitter.rs:1504 in method if !self.short_message {
// remember where we are in the output buffer for easy reference
let buffer_msg_line_offset = buffer.num_lines();
buffer.prepend(buffer_msg_line_offset, "--> ", Style::LineNumber);
buffer.append(
buffer_msg_line_offset,
&format!(
"{}:{}:{}",
sm.filename_for_diagnostics(&loc.file.name),
sm.doctest_offset_line(&loc.file.name, loc.line),
loc.col.0 + 1,
),
Style::LineAndColumn,
);
for _ in 0..max_line_num_len {
buffer.prepend(buffer_msg_line_offset, " ", Style::NoStyle);
}
} else {
buffer.prepend(
0,
&format!(
"{}:{}:{}: ",
sm.filename_for_diagnostics(&loc.file.name),
sm.doctest_offset_line(&loc.file.name, loc.line),
loc.col.0 + 1,
),
Style::LineAndColumn,
);
}Here we have access to the Whereas the let loc = if let Some(first_line) = annotated_file.lines.first() {
let col = if let Some(first_annotation) = first_line.annotations.first() {
format!(":{}", first_annotation.start_col + 1)
} else {
String::new()
};
format!(
"{}:{}{}",
sm.filename_for_diagnostics(&annotated_file.file.name),
sm.doctest_offset_line(&annotated_file.file.name, first_line.line_index),
col
)
} else {
format!("{}", sm.filename_for_diagnostics(&annotated_file.file.name))
};Here we only have an Another possibility for fixing this (other than what I've done in my branch) is to somehow recover/keep the column number from |
|
@rustbot reviewer |
|
Ok, sounds reasonable. |
c0404f7 to
1584b77
Compare
|
There's one more thing I forgot about - could you add the reproduction from #109537 as a test to |
This comment has been minimized.
This comment has been minimized.
1584b77 to
b82608a
Compare
|
@rustbot reviewer |
|
Thanks! |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#109149 (Improve error message when writer is forgotten in write and writeln macro) - rust-lang#109367 (Streamline fast rejection) - rust-lang#109548 (AnnotationColumn struct to fix hard tab column numbers in errors) - rust-lang#109694 (do not panic on failure to acquire jobserver token) - rust-lang#109705 (new solver: check for intercrate mode when accessing the cache) - rust-lang#109708 (Specialization involving RPITITs is broken so ignore the diagnostic differences) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #109537
i don't know if this is the best way of fixing this but it works