From 4a073dda936b2bc594056dca43c3ea51479435fe Mon Sep 17 00:00:00 2001 From: Xavier Denis Date: Tue, 16 Apr 2019 19:26:41 -0300 Subject: Fix #58270, fix off-by-one error in error diagnostics. --- src/librustc_errors/emitter.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/librustc_errors') diff --git a/src/librustc_errors/emitter.rs b/src/librustc_errors/emitter.rs index a1472479afa..c3d594204f4 100644 --- a/src/librustc_errors/emitter.rs +++ b/src/librustc_errors/emitter.rs @@ -268,6 +268,7 @@ impl EmitterWriter { // 6..7. This is degenerate input, but it's best to degrade // gracefully -- and the parser likes to supply a span like // that for EOF, in particular. + if lo.col_display == hi.col_display && lo.line == hi.line { hi.col_display += 1; } @@ -547,6 +548,15 @@ impl EmitterWriter { && j > i // multiline lines). && p == 0 // We're currently on the first line, move the label one line down { + // If we're overlapping with an un-labelled annotation with the same span + // we can just merge them in the output + if next.start_col == annotation.start_col + && next.end_col == annotation.end_col + && !next.has_label() + { + continue; + } + // This annotation needs a new line in the output. p += 1; break; -- cgit 1.4.1-3-g733a5