diff options
| author | bors <bors@rust-lang.org> | 2018-01-30 11:10:06 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-01-30 11:10:06 +0000 |
| commit | def3269a71be2e737cad27418a3dad9f5bd6cd32 (patch) | |
| tree | 1b6a3bf9de28edffa1c9ac671aa066d1c079e35d /src/librustc_errors | |
| parent | fe7e1a45f37f4265434cead827f587e75412f85c (diff) | |
| parent | 393a1994af93977fe1e35fb4ec308bc4e5d1a6dd (diff) | |
Auto merge of #47870 - kennytm:rollup, r=kennytm
Rollup of 12 pull requests - Successful merges: #47515, #47603, #47718, #47732, #47760, #47780, #47822, #47826, #47836, #47839, #47853, #47855 - Failed merges:
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 15 | ||||
| -rw-r--r-- | src/librustc_errors/snippet.rs | 3 |
2 files changed, 16 insertions, 2 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index 8a4fd24a29b..ffb5efd93ed 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -1014,8 +1014,21 @@ impl EmitterWriter { // Then, the secondary file indicator buffer.prepend(buffer_msg_line_offset + 1, "::: ", Style::LineNumber); + 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 { + "".to_string() + }; + format!("{}:{}{}", + annotated_file.file.name, + cm.doctest_offset_line(first_line.line_index), + col) + } else { + annotated_file.file.name.to_string() + }; buffer.append(buffer_msg_line_offset + 1, - &annotated_file.file.name.to_string(), + &loc, Style::LineAndColumn); for _ in 0..max_line_num_len { buffer.prepend(buffer_msg_line_offset + 1, " ", Style::NoStyle); diff --git a/src/librustc_errors/snippet.rs b/src/librustc_errors/snippet.rs index c2f4701999e..6035f33c822 100644 --- a/src/librustc_errors/snippet.rs +++ b/src/librustc_errors/snippet.rs @@ -27,7 +27,8 @@ pub struct FileInfo { /// The "primary file", if any, gets a `-->` marker instead of /// `>>>`, and has a line-number/column printed and not just a - /// filename. It appears first in the listing. It is known to + /// filename (other files are not guaranteed to have line numbers + /// or columns). It appears first in the listing. It is known to /// contain at least one primary span, though primary spans (which /// are designated with `^^^`) may also occur in other files. primary_span: Option<Span>, |
