diff options
| author | bors <bors@rust-lang.org> | 2023-02-09 20:23:00 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-09 20:23:00 +0000 |
| commit | 8996ea93b6e554148c4286e62b613f12a3ee505c (patch) | |
| tree | 1e54719a1d3b2d503d76ad2c7f4bc77d6c51ff45 /compiler/rustc_errors/src | |
| parent | 8cca42a47f5d574c8f7302c98c3f918cdc772fbb (diff) | |
| parent | b080a1a4fc68bc6150a281f21012b79b9f1ee57f (diff) | |
| download | rust-8996ea93b6e554148c4286e62b613f12a3ee505c.tar.gz rust-8996ea93b6e554148c4286e62b613f12a3ee505c.zip | |
Auto merge of #107853 - Dylan-DPC:rollup-macf1qo, r=Dylan-DPC
Rollup of 6 pull requests Successful merges: - #107648 (unused-lifetimes: don't warn about lifetimes originating from expanded code) - #107655 (rustdoc: use the same URL escape rules for fragments as for examples) - #107659 (test: snapshot for derive suggestion in diff files) - #107786 (Implement some tweaks in the new solver) - #107803 (Do not bring trait alias supertraits into scope) - #107815 (Disqualify `auto trait` built-in impl in new solver if explicit `impl` exists) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_errors/src')
| -rw-r--r-- | compiler/rustc_errors/src/emitter.rs | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/compiler/rustc_errors/src/emitter.rs b/compiler/rustc_errors/src/emitter.rs index 9768526a2f4..5f460b26488 100644 --- a/compiler/rustc_errors/src/emitter.rs +++ b/compiler/rustc_errors/src/emitter.rs @@ -1796,17 +1796,17 @@ impl EmitterWriter { // telling users to make a change but not clarifying *where*. let loc = sm.lookup_char_pos(parts[0].span.lo()); if loc.file.name != sm.span_to_filename(span) && loc.file.name.is_real() { - buffer.puts(row_num - 1, 0, "--> ", Style::LineNumber); - buffer.append( - row_num - 1, - &format!( - "{}:{}:{}", - sm.filename_for_diagnostics(&loc.file.name), - sm.doctest_offset_line(&loc.file.name, loc.line), - loc.col.0 + 1, - ), - Style::LineAndColumn, - ); + let arrow = "--> "; + buffer.puts(row_num - 1, 0, arrow, Style::LineNumber); + let filename = sm.filename_for_diagnostics(&loc.file.name); + let offset = sm.doctest_offset_line(&loc.file.name, loc.line); + let message = format!("{}:{}:{}", filename, offset, loc.col.0 + 1); + if row_num == 2 { + let col = usize::max(max_line_num_len + 1, arrow.len()); + buffer.puts(1, col, &message, Style::LineAndColumn); + } else { + buffer.append(row_num - 1, &message, Style::LineAndColumn); + } for _ in 0..max_line_num_len { buffer.prepend(row_num - 1, " ", Style::NoStyle); } |
