about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-04-25 03:05:24 +0200
committerGitHub <noreply@github.com>2019-04-25 03:05:24 +0200
commita4ef188ab6008c6f600e06a7e01e81f75370d574 (patch)
tree0d1e0f669217b452ad987024276fefe008bee236 /src
parentbb892be98edeced022881397b1d64b968943aea7 (diff)
parent4a073dda936b2bc594056dca43c3ea51479435fe (diff)
downloadrust-a4ef188ab6008c6f600e06a7e01e81f75370d574.tar.gz
rust-a4ef188ab6008c6f600e06a7e01e81f75370d574.zip
Rollup merge of #60160 - xldenis:fix-overlapping-zero-width-annotation, r=estebank
Fix #58270, fix off-by-one error in error diagnostics.

This fixes #58270 by checking if two diagnostics overlap completely when we're calculating the line offset for each message.
Diffstat (limited to 'src')
-rw-r--r--src/librustc_errors/emitter.rs10
-rw-r--r--src/test/ui/issue-60075.stderr4
-rw-r--r--src/test/ui/issues/issue-58856-1.stderr5
-rw-r--r--src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr4
-rw-r--r--src/test/ui/parser/issue-10636-2.stderr5
-rw-r--r--src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr4
-rw-r--r--src/test/ui/resolve/token-error-correct-3.stderr5
7 files changed, 19 insertions, 18 deletions
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;
diff --git a/src/test/ui/issue-60075.stderr b/src/test/ui/issue-60075.stderr
index 244aef2d1f0..ac97d32a6e1 100644
--- a/src/test/ui/issue-60075.stderr
+++ b/src/test/ui/issue-60075.stderr
@@ -11,9 +11,7 @@ LL |     fn qux() -> Option<usize> {
    |                               - unclosed delimiter
 LL |         let _ = if true {
 LL |         });
-   |           ^
-   |           |
-   |           help: `}` may belong here
+   |           ^ help: `}` may belong here
 
 error: expected identifier, found `;`
   --> $DIR/issue-60075.rs:6:11
diff --git a/src/test/ui/issues/issue-58856-1.stderr b/src/test/ui/issues/issue-58856-1.stderr
index 20cdf55365f..58ab0a142d6 100644
--- a/src/test/ui/issues/issue-58856-1.stderr
+++ b/src/test/ui/issues/issue-58856-1.stderr
@@ -2,9 +2,8 @@ error: expected one of `)`, `,`, or `:`, found `>`
   --> $DIR/issue-58856-1.rs:2:14
    |
 LL |     fn b(self>
-   |         -    ^
-   |         |    |
-   |         |    help: `)` may belong here
+   |         -    ^ help: `)` may belong here
+   |         |
    |         unclosed delimiter
 
 error: aborting due to previous error
diff --git a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr
index 6484e63223e..b49ee0cfc70 100644
--- a/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr
+++ b/src/test/ui/lifetimes/lifetime-errors/ex3-both-anon-regions-both-are-structs-3.stderr
@@ -2,9 +2,7 @@ error[E0623]: lifetime mismatch
   --> $DIR/ex3-both-anon-regions-both-are-structs-3.rs:7:11
    |
 LL | fn foo(mut x: Ref) {
-   |               ---
-   |               |
-   |               this type is declared with multiple lifetimes...
+   |               --- this type is declared with multiple lifetimes...
 LL |     x.a = x.b;
    |           ^^^ ...but data with one lifetime flows into the other here
 
diff --git a/src/test/ui/parser/issue-10636-2.stderr b/src/test/ui/parser/issue-10636-2.stderr
index 38d57ce5723..5b9a9b7f06c 100644
--- a/src/test/ui/parser/issue-10636-2.stderr
+++ b/src/test/ui/parser/issue-10636-2.stderr
@@ -2,9 +2,8 @@ error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
   --> $DIR/issue-10636-2.rs:5:25
    |
 LL |     option.map(|some| 42;
-   |               -         ^
-   |               |         |
-   |               |         help: `)` may belong here
+   |               -         ^ help: `)` may belong here
+   |               |
    |               unclosed delimiter
 
 error: expected expression, found `)`
diff --git a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr
index 309106e856a..6b3a488805f 100644
--- a/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr
+++ b/src/test/ui/regions/regions-variance-contravariant-use-covariant-in-second-position.stderr
@@ -2,9 +2,7 @@ error[E0623]: lifetime mismatch
   --> $DIR/regions-variance-contravariant-use-covariant-in-second-position.rs:25:30
    |
 LL | fn use_<'short,'long>(c: S<'long, 'short>,
-   |                          ----------------
-   |                          |
-   |                          this type is declared with multiple lifetimes...
+   |                          ---------------- this type is declared with multiple lifetimes...
 ...
 LL |     let _: S<'long, 'long> = c;
    |                              ^ ...but data with one lifetime flows into the other here
diff --git a/src/test/ui/resolve/token-error-correct-3.stderr b/src/test/ui/resolve/token-error-correct-3.stderr
index 5e965e0952c..607573f2769 100644
--- a/src/test/ui/resolve/token-error-correct-3.stderr
+++ b/src/test/ui/resolve/token-error-correct-3.stderr
@@ -2,9 +2,8 @@ error: expected one of `)`, `,`, `.`, `?`, or an operator, found `;`
   --> $DIR/token-error-correct-3.rs:15:35
    |
 LL |             callback(path.as_ref();
-   |                     -             ^
-   |                     |             |
-   |                     |             help: `)` may belong here
+   |                     -             ^ help: `)` may belong here
+   |                     |
    |                     unclosed delimiter
 
 error: expected one of `.`, `;`, `?`, `}`, or an operator, found `)`