about summary refs log tree commit diff
path: root/src/test/ui/span
diff options
context:
space:
mode:
authorManish Goregaokar <manishsmail@gmail.com>2018-02-07 08:30:58 -0800
committerGitHub <noreply@github.com>2018-02-07 08:30:58 -0800
commit732c83007c9069c6dd33a5dc98e62337dca014bd (patch)
tree42fa6ee4ee4bd3b44887c258fb11372a12d0014d /src/test/ui/span
parente2b7458a9740d823e958b0ee2a272917f6938bcd (diff)
parentb55e07ee50c9e4d00b6fc13dc27d45bd03a7965d (diff)
downloadrust-732c83007c9069c6dd33a5dc98e62337dca014bd.tar.gz
rust-732c83007c9069c6dd33a5dc98e62337dca014bd.zip
Rollup merge of #48028 - zackmdavis:and_the_span_of_the_unknown_type, r=estebank
correct E0619 span re method call receivers whose type must be known

Previously, when the type of a method receiver could not be determined,
the error message would, potentially confusingly, highlight the span of
the entire method call.

![unknown_receiver_type](https://user-images.githubusercontent.com/1076988/35838930-a595b17c-0aa2-11e8-9364-6b8e2329f051.png)

Resolves #36598, resolves #42234.
Diffstat (limited to 'src/test/ui/span')
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.rs27
-rw-r--r--src/test/ui/span/issue-42234-unknown-receiver-type.stderr15
2 files changed, 42 insertions, 0 deletions
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.rs b/src/test/ui/span/issue-42234-unknown-receiver-type.rs
new file mode 100644
index 00000000000..d9cdd99c245
--- /dev/null
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.rs
@@ -0,0 +1,27 @@
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// When the type of a method call's receiver is unknown, the span should point
+// to the receiver (and not the entire call, as was previously the case before
+// the fix of which this tests).
+
+fn shines_a_beacon_through_the_darkness() {
+    let x: Option<_> = None;
+    x.unwrap().method_that_could_exist_on_some_type();
+    //~^ ERROR 17:5: 17:15: the type of this value must be known in this context
+}
+
+fn courier_to_des_moines_and_points_west(data: &[u32]) -> String {
+    data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
+        .sum::<_>()
+        .to_string()
+}
+
+fn main() {}
diff --git a/src/test/ui/span/issue-42234-unknown-receiver-type.stderr b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
new file mode 100644
index 00000000000..ed756cdc553
--- /dev/null
+++ b/src/test/ui/span/issue-42234-unknown-receiver-type.stderr
@@ -0,0 +1,15 @@
+error[E0619]: the type of this value must be known in this context
+  --> $DIR/issue-42234-unknown-receiver-type.rs:17:5
+   |
+17 |     x.unwrap().method_that_could_exist_on_some_type();
+   |     ^^^^^^^^^^
+
+error[E0619]: the type of this value must be known in this context
+  --> $DIR/issue-42234-unknown-receiver-type.rs:22:5
+   |
+22 | /     data.iter() //~ ERROR 22:5: 23:20: the type of this value must be known in this context
+23 | |         .sum::<_>()
+   | |___________________^
+
+error: aborting due to 2 previous errors
+