about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorCorey Farwell <coreyf@rwell.org>2017-06-16 00:32:42 -0400
committerGitHub <noreply@github.com>2017-06-16 00:32:42 -0400
commitf784e5f13624f07df27ab76bfd8c8b40f92731bb (patch)
tree0fb6e02bdae2171b38639f29ad3c44336feba9a9 /src/libsyntax
parenta3114961a1c6b8a16cd06a854d585377ac576d47 (diff)
parent8074a88787de412a341e99ea16c88784ecf915a0 (diff)
downloadrust-f784e5f13624f07df27ab76bfd8c8b40f92731bb.tar.gz
rust-f784e5f13624f07df27ab76bfd8c8b40f92731bb.zip
Rollup merge of #42616 - estebank:span-fix, r=nikomatsakis
Position span label correctly when it isn't last

Fix #42595.

Before:

```
15 |     map.entry("e").or_insert(0) += 1;
   |     ---------------------------^^^^^ot use `+=` on type `&mut {integer}`
```

After:

```
15 |     map.entry("e").or_insert(0) += 1;
   |     ---------------------------^^^^^
   |     |
   |     cannot use `+=` on type `&mut {integer}`
```
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/test_snippet.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/libsyntax/test_snippet.rs b/src/libsyntax/test_snippet.rs
index b3fa1e97376..4fae2ff9814 100644
--- a/src/libsyntax/test_snippet.rs
+++ b/src/libsyntax/test_snippet.rs
@@ -736,6 +736,49 @@ error: foo
 }
 
 #[test]
+fn multiple_labels_secondary_without_message_3() {
+    test_harness(r#"
+fn foo() {
+  a  bc  d
+}
+"#,
+    vec![
+        SpanLabel {
+            start: Position {
+                string: "a",
+                count: 1,
+            },
+            end: Position {
+                string: "b",
+                count: 1,
+            },
+            label: "`a` is a good letter",
+        },
+        SpanLabel {
+            start: Position {
+                string: "c",
+                count: 1,
+            },
+            end: Position {
+                string: "d",
+                count: 1,
+            },
+            label: "",
+        },
+    ],
+    r#"
+error: foo
+ --> test.rs:3:3
+  |
+3 |   a  bc  d
+  |   ^^^^----
+  |   |
+  |   `a` is a good letter
+
+"#);
+}
+
+#[test]
 fn multiple_labels_without_message() {
     test_harness(r#"
 fn foo() {