about summary refs log tree commit diff
path: root/src/test/ui
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2017-01-15 05:48:34 +0000
committerbors <bors@rust-lang.org>2017-01-15 05:48:34 +0000
commit4f0508af90cfe4fac018b1a464ed94a828811600 (patch)
treed795bef67c0d54fe193fca200ca6f593842d51dd /src/test/ui
parentbf6d7b665b85506dac663945229f00a406904fa5 (diff)
parentd04c027e9333d632a9ee0dcfbdf0d79dfddf0318 (diff)
downloadrust-4f0508af90cfe4fac018b1a464ed94a828811600.tar.gz
rust-4f0508af90cfe4fac018b1a464ed94a828811600.zip
Auto merge of #39040 - estebank:relevant-impl-multiline, r=nikomatsakis
Use multiline Diagnostic for "relevant impl" list

Provide the following output:

```
error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied
  --> $DIR/issue-21659-show-relevant-trait-impls-2.rs:38:8
   |
38 |     f1.foo(1usize);
   |        ^^^ the trait `Foo<usize>` is not implemented for `Bar`
   |
   = help: the following implementations were found:
             <Bar as Foo<i8>>
             <Bar as Foo<i16>>
             <Bar as Foo<i32>>
             <Bar as Foo<u8>>
           and 2 others

error: aborting due to previous error
```

instead of

```
error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied
  --> $DIR/issue-21659-show-relevant-trait-impls-2.rs:38:8
   |
38 |     f1.foo(1usize);
   |        ^^^ the trait `Foo<usize>` is not implemented for `Bar`
   |
   = help: the following implementations were found:
   = help:   <Bar as Foo<i8>>
   = help:   <Bar as Foo<i16>>
   = help:   <Bar as Foo<i32>>
   = help:   <Bar as Foo<u8>>
   = help: and 2 others

error: aborting due to previous error
```
Diffstat (limited to 'src/test/ui')
-rw-r--r--src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.rs39
-rw-r--r--src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr12
-rw-r--r--src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.rs46
-rw-r--r--src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr15
-rw-r--r--src/test/ui/span/multiline-span-simple.stderr8
5 files changed, 116 insertions, 4 deletions
diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.rs b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.rs
new file mode 100644
index 00000000000..99035209e14
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.rs
@@ -0,0 +1,39 @@
+// Copyright 2015 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.
+
+trait Foo<A> {
+    fn foo(&self, a: A) -> A {
+        a
+    }
+}
+
+trait NotRelevant<A> {
+    fn nr(&self, a: A) -> A {
+        a
+    }
+}
+
+struct Bar;
+
+impl Foo<i32> for Bar {}
+
+impl Foo<u8> for Bar {}
+
+impl NotRelevant<usize> for Bar {}
+
+fn main() {
+    let f1 = Bar;
+
+    f1.foo(1usize);
+    //~^ error: the trait bound `Bar: Foo<usize>` is not satisfied
+    //~| help: the following implementations were found:
+    //~| help:   <Bar as Foo<i32>>
+    //~| help:   <Bar as Foo<u8>>
+}
diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr
new file mode 100644
index 00000000000..9010de081da
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-1.stderr
@@ -0,0 +1,12 @@
+error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied
+  --> $DIR/issue-21659-show-relevant-trait-impls-1.rs:34:8
+   |
+34 |     f1.foo(1usize);
+   |        ^^^ the trait `Foo<usize>` is not implemented for `Bar`
+   |
+   = help: the following implementations were found:
+             <Bar as Foo<i32>>
+             <Bar as Foo<u8>>
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.rs b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.rs
new file mode 100644
index 00000000000..2009c32c854
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.rs
@@ -0,0 +1,46 @@
+// Copyright 2015 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.
+
+trait Foo<A> {
+    fn foo(&self, a: A) -> A {
+        a
+    }
+}
+
+trait NotRelevant<A> {
+    fn nr(&self, a: A) -> A {
+        a
+    }
+}
+
+struct Bar;
+
+impl Foo<i8> for Bar {}
+impl Foo<i16> for Bar {}
+impl Foo<i32> for Bar {}
+
+impl Foo<u8> for Bar {}
+impl Foo<u16> for Bar {}
+impl Foo<u32> for Bar {}
+
+impl NotRelevant<usize> for Bar {}
+
+fn main() {
+    let f1 = Bar;
+
+    f1.foo(1usize);
+    //~^ error: the trait bound `Bar: Foo<usize>` is not satisfied
+    //~| help: the following implementations were found:
+    //~| help:   <Bar as Foo<i8>>
+    //~| help:   <Bar as Foo<i16>>
+    //~| help:   <Bar as Foo<i32>>
+    //~| help:   <Bar as Foo<u8>>
+    //~| help: and 2 others
+}
diff --git a/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr
new file mode 100644
index 00000000000..e9591a64784
--- /dev/null
+++ b/src/test/ui/did_you_mean/issue-21659-show-relevant-trait-impls-2.stderr
@@ -0,0 +1,15 @@
+error[E0277]: the trait bound `Bar: Foo<usize>` is not satisfied
+  --> $DIR/issue-21659-show-relevant-trait-impls-2.rs:38:8
+   |
+38 |     f1.foo(1usize);
+   |        ^^^ the trait `Foo<usize>` is not implemented for `Bar`
+   |
+   = help: the following implementations were found:
+             <Bar as Foo<i8>>
+             <Bar as Foo<i16>>
+             <Bar as Foo<i32>>
+             <Bar as Foo<u8>>
+           and 2 others
+
+error: aborting due to previous error
+
diff --git a/src/test/ui/span/multiline-span-simple.stderr b/src/test/ui/span/multiline-span-simple.stderr
index b801325114c..85c11c05b9f 100644
--- a/src/test/ui/span/multiline-span-simple.stderr
+++ b/src/test/ui/span/multiline-span-simple.stderr
@@ -10,10 +10,10 @@ error[E0277]: the trait bound `u32: std::ops::Add<()>` is not satisfied
    | |______________^ ...ending here: the trait `std::ops::Add<()>` is not implemented for `u32`
    |
    = help: the following implementations were found:
-   = help:   <u32 as std::ops::Add>
-   = help:   <&'a u32 as std::ops::Add<u32>>
-   = help:   <u32 as std::ops::Add<&'a u32>>
-   = help:   <&'b u32 as std::ops::Add<&'a u32>>
+             <u32 as std::ops::Add>
+             <&'a u32 as std::ops::Add<u32>>
+             <u32 as std::ops::Add<&'a u32>>
+             <&'b u32 as std::ops::Add<&'a u32>>
 
 error: aborting due to previous error