diff options
| author | bors <bors@rust-lang.org> | 2018-01-14 11:28:27 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2018-01-14 11:28:27 +0000 |
| commit | 5d6f6e65ffb61a7acec28f1a08491de321e32be5 (patch) | |
| tree | d0cd97e077026036e5c8eb4121c6fbb83a0e40dd /src/librustc_errors | |
| parent | 48ab4cde5460f9f7c57249e4e62ad569dc843dd8 (diff) | |
| parent | 44b659ac2d7563198ce3ae39a4bfcecc6954fe21 (diff) | |
| download | rust-5d6f6e65ffb61a7acec28f1a08491de321e32be5.tar.gz rust-5d6f6e65ffb61a7acec28f1a08491de321e32be5.zip | |
Auto merge of #47274 - Manishearth:rustdoc-span, r=QuietMisdreavus
Use correct line offsets for doctests Not yet tested. This doesn't handle char positions. It could if I collected a map of char offsets and lines, but this is a bit more work and requires hooking into the parser much more (unsure if it's possible). r? @QuietMisdreavus (fixes #45868)
Diffstat (limited to 'src/librustc_errors')
| -rw-r--r-- | src/librustc_errors/emitter.rs | 4 | ||||
| -rw-r--r-- | src/librustc_errors/lib.rs | 1 |
2 files changed, 3 insertions, 2 deletions
diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index af556c576c0..1c3d4af9e18 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -990,7 +990,7 @@ impl EmitterWriter { buffer.append(buffer_msg_line_offset, &format!("{}:{}:{}", loc.file.name, - loc.line, + cm.doctest_offset_line(loc.line), loc.col.0 + 1), Style::LineAndColumn); for _ in 0..max_line_num_len { @@ -1000,7 +1000,7 @@ impl EmitterWriter { buffer.prepend(0, &format!("{}:{}:{} - ", loc.file.name, - loc.line, + cm.doctest_offset_line(loc.line), loc.col.0 + 1), Style::LineAndColumn); } diff --git a/src/librustc_errors/lib.rs b/src/librustc_errors/lib.rs index c48f1761f28..1fb673815ee 100644 --- a/src/librustc_errors/lib.rs +++ b/src/librustc_errors/lib.rs @@ -103,6 +103,7 @@ pub trait CodeMapper { fn merge_spans(&self, sp_lhs: Span, sp_rhs: Span) -> Option<Span>; fn call_span_if_macro(&self, sp: Span) -> Span; fn ensure_filemap_source_present(&self, file_map: Rc<FileMap>) -> bool; + fn doctest_offset_line(&self, line: usize) -> usize; } impl CodeSuggestion { |
