about summary refs log tree commit diff
path: root/src/test/ui/methods
diff options
context:
space:
mode:
authorAaron Hill <aa1ronham@gmail.com>2020-09-26 17:20:14 -0400
committerAaron Hill <aa1ronham@gmail.com>2021-01-26 23:59:50 -0500
commitdea8a16af55e319a41e9451959c68d7a24fcdc5a (patch)
tree1eda1377f7a26233506173d59764d21ebb804963 /src/test/ui/methods
parent78e22069d018e83915201c8a218a0a94227f6420 (diff)
downloadrust-dea8a16af55e319a41e9451959c68d7a24fcdc5a.tar.gz
rust-dea8a16af55e319a41e9451959c68d7a24fcdc5a.zip
Avoid describing a method as 'not found' when bounds are unsatisfied
Fixes #76267

When there is a single applicable method candidate, but its trait bounds
are not satisfied, we avoid saying that the method is "not found".
Insted, we update the error message to directly mention which bounds are
not satisfied, rather than mentioning them in a note.
Diffstat (limited to 'src/test/ui/methods')
-rw-r--r--src/test/ui/methods/method-call-err-msg.rs2
-rw-r--r--src/test/ui/methods/method-call-err-msg.stderr6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/test/ui/methods/method-call-err-msg.rs b/src/test/ui/methods/method-call-err-msg.rs
index 9bfacc7babf..86d00ca3760 100644
--- a/src/test/ui/methods/method-call-err-msg.rs
+++ b/src/test/ui/methods/method-call-err-msg.rs
@@ -16,7 +16,7 @@ fn main() {
 
     let y = Foo;
     y.zero()
-     .take()    //~ ERROR no method named `take` found
+     .take()    //~ ERROR the method
      .one(0);
     y.three::<usize>(); //~ ERROR this function takes 3 arguments but 0 arguments were supplied
 }
diff --git a/src/test/ui/methods/method-call-err-msg.stderr b/src/test/ui/methods/method-call-err-msg.stderr
index 60f9eeeca27..ffeacfe15dd 100644
--- a/src/test/ui/methods/method-call-err-msg.stderr
+++ b/src/test/ui/methods/method-call-err-msg.stderr
@@ -40,7 +40,7 @@ note: associated function defined here
 LL |     fn two(self, _: isize, _: isize) -> Foo { self }
    |        ^^^ ----  --------  --------
 
-error[E0599]: no method named `take` found for struct `Foo` in the current scope
+error[E0599]: the method `take` exists for struct `Foo`, but its trait bounds were not satisfied
   --> $DIR/method-call-err-msg.rs:19:7
    |
 LL | pub struct Foo;
@@ -50,9 +50,9 @@ LL | pub struct Foo;
    | doesn't satisfy `Foo: Iterator`
 ...
 LL |      .take()
-   |       ^^^^ method not found in `Foo`
+   |       ^^^^ method cannot be called on `Foo` due to unsatisfied trait bounds
    |
-   = note: the method `take` exists but the following trait bounds were not satisfied:
+   = note: the following trait bounds were not satisfied:
            `Foo: Iterator`
            which is required by `&mut Foo: Iterator`
    = help: items from traits can only be used if the trait is implemented and in scope