about summary refs log tree commit diff
path: root/src/test/ui/suggestions
diff options
context:
space:
mode:
authorEsteban Kuber <esteban@kuber.com.ar>2021-10-05 23:04:09 +0000
committerEsteban Kuber <esteban@kuber.com.ar>2021-11-20 18:54:31 +0000
commit6b9d910639d50a26cec46e326e1556665b22decf (patch)
tree773eff83fdd65cbe5b397373665889c97d4eccb2 /src/test/ui/suggestions
parent93542a8240c5f926ac5f3f99cef99366082f9c2b (diff)
downloadrust-6b9d910639d50a26cec46e326e1556665b22decf.tar.gz
rust-6b9d910639d50a26cec46e326e1556665b22decf.zip
Point at source of trait bound obligations in more places
Be more thorough in using `ItemObligation` and `BindingObligation` when
evaluating obligations so that we can point at trait bounds that
introduced unfulfilled obligations. We no longer incorrectly point at
unrelated trait bounds (`substs-ppaux.verbose.stderr`).

In particular, we now point at trait bounds on method calls.

We no longer point at "obvious" obligation sources (we no longer have a
note pointing at `Trait` saying "required by a bound in `Trait`", like
in `associated-types-no-suitable-supertrait*`).

Address part of #89418.
Diffstat (limited to 'src/test/ui/suggestions')
-rw-r--r--src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr12
-rw-r--r--src/test/ui/suggestions/issue-62843.stderr5
-rw-r--r--src/test/ui/suggestions/issue-71394-no-from-impl.stderr5
-rw-r--r--src/test/ui/suggestions/issue-84973.stderr9
-rw-r--r--src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr7
-rw-r--r--src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr6
-rw-r--r--src/test/ui/suggestions/suggest-change-mut.stderr6
7 files changed, 34 insertions, 16 deletions
diff --git a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
index aa3175dae2e..7ef4895249c 100644
--- a/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
+++ b/src/test/ui/suggestions/expected-boxed-future-isnt-pinned.stderr
@@ -46,11 +46,11 @@ LL |     Pin::new(x)
    |     ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
    |
    = note: consider using `Box::pin`
-note: required by `Pin::<P>::new`
+note: required by a bound in `Pin::<P>::new`
   --> $SRC_DIR/core/src/pin.rs:LL:COL
    |
-LL |     pub const fn new(pointer: P) -> Pin<P> {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<P: Deref<Target: Unpin>> Pin<P> {
+   |                       ^^^^^ required by this bound in `Pin::<P>::new`
 
 error[E0277]: `dyn Future<Output = i32> + Send` cannot be unpinned
   --> $DIR/expected-boxed-future-isnt-pinned.rs:24:5
@@ -59,11 +59,11 @@ LL |     Pin::new(Box::new(x))
    |     ^^^^^^^^ the trait `Unpin` is not implemented for `dyn Future<Output = i32> + Send`
    |
    = note: consider using `Box::pin`
-note: required by `Pin::<P>::new`
+note: required by a bound in `Pin::<P>::new`
   --> $SRC_DIR/core/src/pin.rs:LL:COL
    |
-LL |     pub const fn new(pointer: P) -> Pin<P> {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<P: Deref<Target: Unpin>> Pin<P> {
+   |                       ^^^^^ required by this bound in `Pin::<P>::new`
 
 error[E0308]: mismatched types
   --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5
diff --git a/src/test/ui/suggestions/issue-62843.stderr b/src/test/ui/suggestions/issue-62843.stderr
index 29ba39cbe10..bc1c69406d1 100644
--- a/src/test/ui/suggestions/issue-62843.stderr
+++ b/src/test/ui/suggestions/issue-62843.stderr
@@ -8,6 +8,11 @@ LL |     println!("{:?}", line.find(pattern));
    |
    = note: the trait bound `String: Pattern<'_>` is not satisfied
    = note: required because of the requirements on the impl of `Pattern<'_>` for `String`
+note: required by a bound in `core::str::<impl str>::find`
+  --> $SRC_DIR/core/src/str/mod.rs:LL:COL
+   |
+LL |     pub fn find<'a, P: Pattern<'a>>(&'a self, pat: P) -> Option<usize> {
+   |                        ^^^^^^^^^^^ required by this bound in `core::str::<impl str>::find`
 help: consider borrowing here
    |
 LL |     println!("{:?}", line.find(&pattern));
diff --git a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr
index 79724377713..bee29dbb079 100644
--- a/src/test/ui/suggestions/issue-71394-no-from-impl.stderr
+++ b/src/test/ui/suggestions/issue-71394-no-from-impl.stderr
@@ -8,6 +8,11 @@ LL |     let _: &[i8] = data.into();
              <[T; LANES] as From<Simd<T, LANES>>>
              <[bool; LANES] as From<Mask<T, LANES>>>
    = note: required because of the requirements on the impl of `Into<&[i8]>` for `&[u8]`
+note: required by `into`
+  --> $SRC_DIR/core/src/convert/mod.rs:LL:COL
+   |
+LL |     fn into(self) -> T;
+   |     ^^^^^^^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/issue-84973.stderr b/src/test/ui/suggestions/issue-84973.stderr
index 16a28c73aa7..24c989ec3e8 100644
--- a/src/test/ui/suggestions/issue-84973.stderr
+++ b/src/test/ui/suggestions/issue-84973.stderr
@@ -6,11 +6,14 @@ LL |     let o = Other::new(f);
    |             |
    |             required by a bound introduced by this call
    |
-note: required by `Other::<'a, G>::new`
-  --> $DIR/issue-84973.rs:27:5
+note: required by a bound in `Other::<'a, G>::new`
+  --> $DIR/issue-84973.rs:25:8
    |
+LL |     G: SomeTrait,
+   |        ^^^^^^^^^ required by this bound in `Other::<'a, G>::new`
+LL | {
 LL |     pub fn new(g: G) -> Self {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^
+   |            --- required by a bound in this
 help: consider borrowing here
    |
 LL |     let o = Other::new(&f);
diff --git a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
index 0cf0074dc3d..adb928aa8a3 100644
--- a/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
+++ b/src/test/ui/suggestions/lifetimes/missing-lifetimes-in-signature-2.stderr
@@ -11,11 +11,16 @@ note: the parameter type `T` must be valid for the anonymous lifetime defined he
    |
 LL | fn func<T: Test>(foo: &Foo, t: T) {
    |                        ^^^
-note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds
+note: ...so that the type `[closure@$DIR/missing-lifetimes-in-signature-2.rs:20:13: 23:6]` will meet its required lifetime bounds...
   --> $DIR/missing-lifetimes-in-signature-2.rs:20:9
    |
 LL |     foo.bar(move |_| {
    |         ^^^
+note: ...that is required by this bound
+  --> $DIR/missing-lifetimes-in-signature-2.rs:11:12
+   |
+LL |         F: 'a,
+   |            ^^
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr
index e6a22313900..d121932c842 100644
--- a/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr
+++ b/src/test/ui/suggestions/mut-borrow-needed-by-trait.stderr
@@ -7,11 +7,11 @@ LL |     let fp = BufWriter::new(fp);
    |              required by a bound introduced by this call
    |
    = note: `std::io::Write` is implemented for `&mut dyn std::io::Write`, but not for `&dyn std::io::Write`
-note: required by `BufWriter::<W>::new`
+note: required by a bound in `BufWriter::<W>::new`
   --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL
    |
-LL |     pub fn new(inner: W) -> BufWriter<W> {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<W: Write> BufWriter<W> {
+   |         ^^^^^ required by this bound in `BufWriter::<W>::new`
 
 error[E0277]: the trait bound `&dyn std::io::Write: std::io::Write` is not satisfied
   --> $DIR/mut-borrow-needed-by-trait.rs:17:14
diff --git a/src/test/ui/suggestions/suggest-change-mut.stderr b/src/test/ui/suggestions/suggest-change-mut.stderr
index 8dfab8dfa17..2fa69cd5a2c 100644
--- a/src/test/ui/suggestions/suggest-change-mut.stderr
+++ b/src/test/ui/suggestions/suggest-change-mut.stderr
@@ -6,11 +6,11 @@ LL |         let mut stream_reader = BufReader::new(&stream);
    |                                 |
    |                                 required by a bound introduced by this call
    |
-note: required by `BufReader::<R>::new`
+note: required by a bound in `BufReader::<R>::new`
   --> $SRC_DIR/std/src/io/buffered/bufreader.rs:LL:COL
    |
-LL |     pub fn new(inner: R) -> BufReader<R> {
-   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+LL | impl<R: Read> BufReader<R> {
+   |         ^^^^ required by this bound in `BufReader::<R>::new`
 help: consider removing the leading `&`-reference
    |
 LL -         let mut stream_reader = BufReader::new(&stream);