about summary refs log tree commit diff
path: root/src/test/ui/methods
diff options
context:
space:
mode:
authorMazdak Farrokhzad <twingoow@gmail.com>2019-12-20 12:17:20 +0100
committerGitHub <noreply@github.com>2019-12-20 12:17:20 +0100
commitf0eb4b4752424233e64b19ae242c052eaa65e1ce (patch)
tree5c05ad84c8d17d0dc2e6000ec37a886647174095 /src/test/ui/methods
parent57da9d32693e960f401003a206adfcc32364452c (diff)
parent8c4f1d5f875e29e9a6e063744b71dc0a3c7deb6d (diff)
Rollup merge of #67127 - estebank:disambiguate-suggestion, r=varkor
Use structured suggestion for disambiguating method calls

Fix #65635.
Diffstat (limited to 'src/test/ui/methods')
-rw-r--r--src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr10
-rw-r--r--src/test/ui/methods/method-ambig-two-traits-from-bounds.stderr10
-rw-r--r--src/test/ui/methods/method-ambig-two-traits-from-impls.stderr10
-rw-r--r--src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr10
-rw-r--r--src/test/ui/methods/method-ambig-two-traits-with-default-method.stderr10
-rw-r--r--src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr15
6 files changed, 52 insertions, 13 deletions
diff --git a/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr b/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr
index 9f46a722a50..fa3add81a28 100644
--- a/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr
+++ b/src/test/ui/methods/method-ambig-two-traits-cross-crate.stderr
@@ -9,9 +9,15 @@ note: candidate #1 is defined in an impl of the trait `Me2` for the type `usize`
    |
 LL | impl Me2 for usize { fn me(&self) -> usize { *self } }
    |                      ^^^^^^^^^^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `Me2::me(1_usize)` instead
    = note: candidate #2 is defined in an impl of the trait `ambig_impl_2_lib::Me` for the type `usize`
-   = help: to disambiguate the method call, write `ambig_impl_2_lib::Me::me(1_usize)` instead
+help: disambiguate the method call for candidate #1
+   |
+LL | fn main() { Me2::me(&1_usize); }
+   |             ^^^^^^^^^^^^^^^^^
+help: disambiguate the method call for candidate #2
+   |
+LL | fn main() { ambig_impl_2_lib::Me::me(&1_usize); }
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/methods/method-ambig-two-traits-from-bounds.stderr b/src/test/ui/methods/method-ambig-two-traits-from-bounds.stderr
index 6c493c67e29..b6c81c2377e 100644
--- a/src/test/ui/methods/method-ambig-two-traits-from-bounds.stderr
+++ b/src/test/ui/methods/method-ambig-two-traits-from-bounds.stderr
@@ -9,13 +9,19 @@ note: candidate #1 is defined in the trait `A`
    |
 LL | trait A { fn foo(&self); }
    |           ^^^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `A::foo(t)` instead
 note: candidate #2 is defined in the trait `B`
   --> $DIR/method-ambig-two-traits-from-bounds.rs:2:11
    |
 LL | trait B { fn foo(&self); }
    |           ^^^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `B::foo(t)` instead
+help: disambiguate the method call for candidate #1
+   |
+LL |     A::foo(t);
+   |     ^^^^^^^^^
+help: disambiguate the method call for candidate #2
+   |
+LL |     B::foo(t);
+   |     ^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/methods/method-ambig-two-traits-from-impls.stderr b/src/test/ui/methods/method-ambig-two-traits-from-impls.stderr
index 0b3724e030f..71c65f7ccc6 100644
--- a/src/test/ui/methods/method-ambig-two-traits-from-impls.stderr
+++ b/src/test/ui/methods/method-ambig-two-traits-from-impls.stderr
@@ -9,13 +9,19 @@ note: candidate #1 is defined in an impl of the trait `A` for the type `AB`
    |
 LL |     fn foo(self) {}
    |     ^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `A::foo(AB {})` instead
 note: candidate #2 is defined in an impl of the trait `B` for the type `AB`
   --> $DIR/method-ambig-two-traits-from-impls.rs:11:5
    |
 LL |     fn foo(self) {}
    |     ^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `B::foo(AB {})` instead
+help: disambiguate the method call for candidate #1
+   |
+LL |     A::foo(AB {});
+   |     ^^^^^^^^^^^^^
+help: disambiguate the method call for candidate #2
+   |
+LL |     B::foo(AB {});
+   |     ^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr b/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr
index 81c99b33c81..44f85071505 100644
--- a/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr
+++ b/src/test/ui/methods/method-ambig-two-traits-from-impls2.stderr
@@ -9,13 +9,19 @@ note: candidate #1 is defined in an impl of the trait `A` for the type `AB`
    |
 LL |     fn foo() {}
    |     ^^^^^^^^
-   = help: to disambiguate the method call, write `A::foo(...)` instead
 note: candidate #2 is defined in an impl of the trait `B` for the type `AB`
   --> $DIR/method-ambig-two-traits-from-impls2.rs:11:5
    |
 LL |     fn foo() {}
    |     ^^^^^^^^
-   = help: to disambiguate the method call, write `B::foo(...)` instead
+help: disambiguate the method call for candidate #1
+   |
+LL |     A::foo();
+   |     ^^^^^^
+help: disambiguate the method call for candidate #2
+   |
+LL |     B::foo();
+   |     ^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/methods/method-ambig-two-traits-with-default-method.stderr b/src/test/ui/methods/method-ambig-two-traits-with-default-method.stderr
index dc8aef25037..3dbb1737100 100644
--- a/src/test/ui/methods/method-ambig-two-traits-with-default-method.stderr
+++ b/src/test/ui/methods/method-ambig-two-traits-with-default-method.stderr
@@ -9,13 +9,19 @@ note: candidate #1 is defined in an impl of the trait `Foo` for the type `usize`
    |
 LL | trait Foo { fn method(&self) {} }
    |             ^^^^^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `Foo::method(1_usize)` instead
 note: candidate #2 is defined in an impl of the trait `Bar` for the type `usize`
   --> $DIR/method-ambig-two-traits-with-default-method.rs:6:13
    |
 LL | trait Bar { fn method(&self) {} }
    |             ^^^^^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `Bar::method(1_usize)` instead
+help: disambiguate the method call for candidate #1
+   |
+LL |     Foo::method(&1_usize);
+   |     ^^^^^^^^^^^^^^^^^^^^^
+help: disambiguate the method call for candidate #2
+   |
+LL |     Bar::method(&1_usize);
+   |     ^^^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
index c9d7da84e09..e7f295df8c4 100644
--- a/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
+++ b/src/test/ui/methods/method-deref-to-same-trait-object-with-separate-params.stderr
@@ -25,19 +25,28 @@ note: candidate #1 is defined in an impl of the trait `internal::X` for the type
    |
 LL |         fn foo(self: Smaht<Self, u64>) -> u64 {
    |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `internal::X::foo(x)` instead
 note: candidate #2 is defined in an impl of the trait `nuisance_foo::NuisanceFoo` for the type `_`
   --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:70:9
    |
 LL |         fn foo(self) {}
    |         ^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `nuisance_foo::NuisanceFoo::foo(x)` instead
 note: candidate #3 is defined in the trait `FinalFoo`
   --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:57:5
    |
 LL |     fn foo(&self) -> u8;
    |     ^^^^^^^^^^^^^^^^^^^^
-   = help: to disambiguate the method call, write `FinalFoo::foo(x)` instead
+help: disambiguate the method call for candidate #1
+   |
+LL |     let z = internal::X::foo(x);
+   |             ^^^^^^^^^^^^^^^^^^^
+help: disambiguate the method call for candidate #2
+   |
+LL |     let z = nuisance_foo::NuisanceFoo::foo(x);
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+help: disambiguate the method call for candidate #3
+   |
+LL |     let z = FinalFoo::foo(x);
+   |             ^^^^^^^^^^^^^^^^
 
 error[E0308]: mismatched types
   --> $DIR/method-deref-to-same-trait-object-with-separate-params.rs:137:24