about summary refs log tree commit diff
path: root/tests/ui
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2023-07-22 19:57:35 +0200
committerGitHub <noreply@github.com>2023-07-22 19:57:35 +0200
commit0ed5f091a630a8f2812645e9a2d439a3b081a561 (patch)
treeaac09f7d1dad4008f3db4201bc17975d44858b7e /tests/ui
parentab0f3e680e4fd50218914b8afa6900a67377721c (diff)
parent8745ae21f9acd17fb3e3d1f9556280e652e996a0 (diff)
Rollup merge of #112508 - compiler-errors:trait-sig-lifetime-sugg-ice, r=cjgillot
Tweak spans for self arg, fix borrow suggestion for signature mismatch

1. Adjust a suggestion message that was annoying me
2. Fix #112503 by recording the right spans for the `self` part of the `&self` 0th argument
3. Remove the suggestion for adjusting a trait signature on type mismatch, bc that's gonna probably break all the other impls of the trait even if it fixes its one usage :sweat_smile:
Diffstat (limited to 'tests/ui')
-rw-r--r--tests/ui/anonymous-higher-ranked-lifetime.stderr22
-rw-r--r--tests/ui/closures/multiple-fn-bounds.stderr2
-rw-r--r--tests/ui/dropck/explicit-drop-bounds.bad1.stderr4
-rw-r--r--tests/ui/dropck/explicit-drop-bounds.bad2.stderr4
-rw-r--r--tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr4
-rw-r--r--tests/ui/mismatched_types/closure-arg-type-mismatch.stderr2
-rw-r--r--tests/ui/mismatched_types/issue-36053-2.stderr2
-rw-r--r--tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr2
-rw-r--r--tests/ui/mismatched_types/suggest-option-asderef.fixed2
-rw-r--r--tests/ui/mismatched_types/suggest-option-asderef.rs2
-rw-r--r--tests/ui/mismatched_types/suggest-option-asderef.stderr2
-rw-r--r--tests/ui/specialization/min_specialization/issue-79224.stderr4
-rw-r--r--tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr2
-rw-r--r--tests/ui/typeck/mismatched-map-under-self.rs17
-rw-r--r--tests/ui/typeck/mismatched-map-under-self.stderr37
15 files changed, 81 insertions, 27 deletions
diff --git a/tests/ui/anonymous-higher-ranked-lifetime.stderr b/tests/ui/anonymous-higher-ranked-lifetime.stderr
index c023d1b1590..e441cbdc866 100644
--- a/tests/ui/anonymous-higher-ranked-lifetime.stderr
+++ b/tests/ui/anonymous-higher-ranked-lifetime.stderr
@@ -13,7 +13,7 @@ note: required by a bound in `f1`
    |
 LL | fn f1<F>(_: F) where F: Fn(&(), &()) {}
    |                         ^^^^^^^^^^^^ required by this bound in `f1`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its arguments
    |
 LL |     f1(|_: &(), _: &()| {});
    |            +       +
@@ -33,7 +33,7 @@ note: required by a bound in `f2`
    |
 LL | fn f2<F>(_: F) where F: for<'a> Fn(&'a (), &()) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f2`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its arguments
    |
 LL |     f2(|_: &(), _: &()| {});
    |            +       +
@@ -53,7 +53,7 @@ note: required by a bound in `f3`
    |
 LL | fn f3<'a, F>(_: F) where F: Fn(&'a (), &()) {}
    |                             ^^^^^^^^^^^^^^^ required by this bound in `f3`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its arguments
    |
 LL |     f3(|_: &(), _: &()| {});
    |            +       +
@@ -73,7 +73,7 @@ note: required by a bound in `f4`
    |
 LL | fn f4<F>(_: F) where F: for<'r> Fn(&(), &'r ()) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f4`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its arguments
    |
 LL |     f4(|_: &(), _: &()| {});
    |            +       +
@@ -93,7 +93,7 @@ note: required by a bound in `f5`
    |
 LL | fn f5<F>(_: F) where F: for<'r> Fn(&'r (), &'r ()) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `f5`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its arguments
    |
 LL |     f5(|_: &(), _: &()| {});
    |            +       +
@@ -113,7 +113,7 @@ note: required by a bound in `g1`
    |
 LL | fn g1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g1`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     g1(|_: &(), _: ()| {});
    |            +
@@ -133,7 +133,7 @@ note: required by a bound in `g2`
    |
 LL | fn g2<F>(_: F) where F: Fn(&(), fn(&())) {}
    |                         ^^^^^^^^^^^^^^^^ required by this bound in `g2`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     g2(|_: &(), _: ()| {});
    |            +
@@ -153,7 +153,7 @@ note: required by a bound in `g3`
    |
 LL | fn g3<F>(_: F) where F: for<'s> Fn(&'s (), Box<dyn Fn(&())>) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g3`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     g3(|_: &(), _: ()| {});
    |            +
@@ -173,7 +173,7 @@ note: required by a bound in `g4`
    |
 LL | fn g4<F>(_: F) where F: Fn(&(), for<'r> fn(&'r ())) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `g4`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     g4(|_: &(), _: ()| {});
    |            +
@@ -193,7 +193,7 @@ note: required by a bound in `h1`
    |
 LL | fn h1<F>(_: F) where F: Fn(&(), Box<dyn Fn(&())>, &(), fn(&(), &())) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h1`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its arguments
    |
 LL |     h1(|_: &(), _: (), _: &(), _: ()| {});
    |            +              +
@@ -213,7 +213,7 @@ note: required by a bound in `h2`
    |
 LL | fn h2<F>(_: F) where F: for<'t0> Fn(&(), Box<dyn Fn(&())>, &'t0 (), fn(&(), &())) {}
    |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `h2`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its arguments
    |
 LL |     h2(|_: &(), _: (), _: &(), _: ()| {});
    |            +              +
diff --git a/tests/ui/closures/multiple-fn-bounds.stderr b/tests/ui/closures/multiple-fn-bounds.stderr
index 32a1edb0024..d94c902f721 100644
--- a/tests/ui/closures/multiple-fn-bounds.stderr
+++ b/tests/ui/closures/multiple-fn-bounds.stderr
@@ -18,7 +18,7 @@ note: required by a bound in `foo`
    |
 LL | fn foo<F: Fn(&char) -> bool + Fn(char) -> bool>(f: F) {
    |                               ^^^^^^^^^^^^^^^^ required by this bound in `foo`
-help: do not borrow the argument
+help: consider adjusting the signature so it does not borrow its argument
    |
 LL |     foo(move |char| v);
    |               ~~~~
diff --git a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr
index 3b506c7e7ec..3ef11e2c0bb 100644
--- a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr
+++ b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr
@@ -15,10 +15,10 @@ LL |     [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply
    |                 ~~~~~~~~~~~~~~~~~~~~~~
 
 error[E0277]: the trait bound `T: Copy` is not satisfied
-  --> $DIR/explicit-drop-bounds.rs:32:13
+  --> $DIR/explicit-drop-bounds.rs:32:18
    |
 LL |     fn drop(&mut self) {}
-   |             ^^^^^^^^^ the trait `Copy` is not implemented for `T`
+   |                  ^^^^ the trait `Copy` is not implemented for `T`
    |
 note: required by a bound in `DropMe`
   --> $DIR/explicit-drop-bounds.rs:7:18
diff --git a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr
index 832af3e521a..8138b86ddea 100644
--- a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr
+++ b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr
@@ -15,10 +15,10 @@ LL | impl<T: std::marker::Copy> Drop for DropMe<T>
    |       +++++++++++++++++++
 
 error[E0277]: the trait bound `T: Copy` is not satisfied
-  --> $DIR/explicit-drop-bounds.rs:40:13
+  --> $DIR/explicit-drop-bounds.rs:40:18
    |
 LL |     fn drop(&mut self) {}
-   |             ^^^^^^^^^ the trait `Copy` is not implemented for `T`
+   |                  ^^^^ the trait `Copy` is not implemented for `T`
    |
 note: required by a bound in `DropMe`
   --> $DIR/explicit-drop-bounds.rs:7:18
diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr
index fb8af4bb7dd..452cba6b4de 100644
--- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr
+++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.stderr
@@ -10,7 +10,7 @@ LL |     let _ = (-10..=10).find(|x: i32| x.signum() == 0);
               found closure signature `fn(i32) -> _`
 note: required by a bound in `find`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     let _ = (-10..=10).find(|x: &i32| x.signum() == 0);
    |                                 +
@@ -27,7 +27,7 @@ LL |     let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0);
               found closure signature `for<'a, 'b, 'c> fn(&'a &'b &'c i32) -> _`
 note: required by a bound in `find`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
-help: do not borrow the argument
+help: consider adjusting the signature so it does not borrow its argument
    |
 LL -     let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0);
 LL +     let _ = (-10..=10).find(|x: &i32| x.signum() == 0);
diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr
index 811ff0533f0..760e3327b77 100644
--- a/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr
+++ b/tests/ui/mismatched_types/closure-arg-type-mismatch.stderr
@@ -10,7 +10,7 @@ LL |     a.iter().map(|_: (u32, u32)| 45);
               found closure signature `fn((u32, u32)) -> _`
 note: required by a bound in `map`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     a.iter().map(|_: &(u32, u32)| 45);
    |                      +
diff --git a/tests/ui/mismatched_types/issue-36053-2.stderr b/tests/ui/mismatched_types/issue-36053-2.stderr
index a6764a1dc6d..4d230ce9a7a 100644
--- a/tests/ui/mismatched_types/issue-36053-2.stderr
+++ b/tests/ui/mismatched_types/issue-36053-2.stderr
@@ -10,7 +10,7 @@ LL |     once::<&str>("str").fuse().filter(|a: &str| true).count();
               found closure signature `for<'a> fn(&'a str) -> _`
 note: required by a bound in `filter`
   --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     once::<&str>("str").fuse().filter(|a: &&str| true).count();
    |                                           +
diff --git a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr
index 71c4729e310..5c4c13266d0 100644
--- a/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr
+++ b/tests/ui/mismatched_types/suggest-option-asderef-inference-var.stderr
@@ -13,7 +13,7 @@ LL |     let _has_inference_vars: Option<i32> = Some(0).map(deref_int);
               found function signature `for<'a> fn(&'a i32) -> _`
 note: required by a bound in `Option::<T>::map`
   --> $SRC_DIR/core/src/option.rs:LL:COL
-help: do not borrow the argument
+help: consider adjusting the signature so it does not borrow its argument
    |
 LL - fn deref_int(a: &i32) -> i32 {
 LL + fn deref_int(a: i32) -> i32 {
diff --git a/tests/ui/mismatched_types/suggest-option-asderef.fixed b/tests/ui/mismatched_types/suggest-option-asderef.fixed
index 5c42ece3c5d..fc488b790b3 100644
--- a/tests/ui/mismatched_types/suggest-option-asderef.fixed
+++ b/tests/ui/mismatched_types/suggest-option-asderef.fixed
@@ -17,7 +17,7 @@ fn generic<T>(_: T) -> Option<()> {
 }
 
 fn generic_ref<T>(_: T) -> Option<()> {
-    //~^ HELP do not borrow the argument
+    //~^ HELP consider adjusting the signature so it does not borrow its argument
     Some(())
 }
 
diff --git a/tests/ui/mismatched_types/suggest-option-asderef.rs b/tests/ui/mismatched_types/suggest-option-asderef.rs
index a5278b8fb16..28f46808a39 100644
--- a/tests/ui/mismatched_types/suggest-option-asderef.rs
+++ b/tests/ui/mismatched_types/suggest-option-asderef.rs
@@ -17,7 +17,7 @@ fn generic<T>(_: T) -> Option<()> {
 }
 
 fn generic_ref<T>(_: &T) -> Option<()> {
-    //~^ HELP do not borrow the argument
+    //~^ HELP consider adjusting the signature so it does not borrow its argument
     Some(())
 }
 
diff --git a/tests/ui/mismatched_types/suggest-option-asderef.stderr b/tests/ui/mismatched_types/suggest-option-asderef.stderr
index 01341603dde..bfea0867350 100644
--- a/tests/ui/mismatched_types/suggest-option-asderef.stderr
+++ b/tests/ui/mismatched_types/suggest-option-asderef.stderr
@@ -73,7 +73,7 @@ LL |     let _ = produces_string().and_then(generic_ref);
               found function signature `for<'a> fn(&'a _) -> _`
 note: required by a bound in `Option::<T>::and_then`
   --> $SRC_DIR/core/src/option.rs:LL:COL
-help: do not borrow the argument
+help: consider adjusting the signature so it does not borrow its argument
    |
 LL - fn generic_ref<T>(_: &T) -> Option<()> {
 LL + fn generic_ref<T>(_: T) -> Option<()> {
diff --git a/tests/ui/specialization/min_specialization/issue-79224.stderr b/tests/ui/specialization/min_specialization/issue-79224.stderr
index 505baa23ca3..9a4d557a152 100644
--- a/tests/ui/specialization/min_specialization/issue-79224.stderr
+++ b/tests/ui/specialization/min_specialization/issue-79224.stderr
@@ -11,10 +11,10 @@ LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> {
    |                +++++++++++++++++++
 
 error[E0277]: the trait bound `B: Clone` is not satisfied
-  --> $DIR/issue-79224.rs:20:12
+  --> $DIR/issue-79224.rs:20:13
    |
 LL |     fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
-   |            ^^^^^ the trait `Clone` is not implemented for `B`
+   |             ^^^^ the trait `Clone` is not implemented for `B`
    |
    = note: required for `B` to implement `ToOwned`
 help: consider further restricting this bound
diff --git a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr
index 6820af1fd45..a03d4e8ce9f 100644
--- a/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr
+++ b/tests/ui/suggestions/late-bound-in-borrow-closure-sugg.stderr
@@ -16,7 +16,7 @@ note: required by a bound in `Trader::<'a>::set_closure`
    |
 LL |     pub fn set_closure(&mut self, function: impl Fn(&mut Trader) + 'a) {
    |                                                  ^^^^^^^^^^^^^^^ required by this bound in `Trader::<'a>::set_closure`
-help: consider borrowing the argument
+help: consider adjusting the signature so it borrows its argument
    |
 LL |     let closure = |trader : &mut Trader| {
    |                             ++++
diff --git a/tests/ui/typeck/mismatched-map-under-self.rs b/tests/ui/typeck/mismatched-map-under-self.rs
new file mode 100644
index 00000000000..bedb7a1907d
--- /dev/null
+++ b/tests/ui/typeck/mismatched-map-under-self.rs
@@ -0,0 +1,17 @@
+pub trait Insertable {
+    type Values;
+
+    fn values(&self) -> Self::Values;
+}
+
+impl<T> Insertable for Option<T> {
+    type Values = ();
+
+    fn values(self) -> Self::Values {
+        //~^ ERROR method `values` has an incompatible type for trait
+        self.map(Insertable::values).unwrap_or_default()
+        //~^ ERROR type mismatch in function arguments
+    }
+}
+
+fn main() {}
diff --git a/tests/ui/typeck/mismatched-map-under-self.stderr b/tests/ui/typeck/mismatched-map-under-self.stderr
new file mode 100644
index 00000000000..51491407c49
--- /dev/null
+++ b/tests/ui/typeck/mismatched-map-under-self.stderr
@@ -0,0 +1,37 @@
+error[E0053]: method `values` has an incompatible type for trait
+  --> $DIR/mismatched-map-under-self.rs:10:15
+   |
+LL |     fn values(self) -> Self::Values {
+   |               ^^^^
+   |               |
+   |               expected `&Option<T>`, found `Option<T>`
+   |               help: change the self-receiver type to match the trait: `&self`
+   |
+note: type in trait
+  --> $DIR/mismatched-map-under-self.rs:4:15
+   |
+LL |     fn values(&self) -> Self::Values;
+   |               ^^^^^
+   = note: expected signature `fn(&Option<T>)`
+              found signature `fn(Option<T>)`
+
+error[E0631]: type mismatch in function arguments
+  --> $DIR/mismatched-map-under-self.rs:12:18
+   |
+LL |     fn values(&self) -> Self::Values;
+   |     --------------------------------- found signature defined here
+...
+LL |         self.map(Insertable::values).unwrap_or_default()
+   |              --- ^^^^^^^^^^^^^^^^^^ expected due to this
+   |              |
+   |              required by a bound introduced by this call
+   |
+   = note: expected function signature `fn(T) -> _`
+              found function signature `for<'a> fn(&'a _) -> _`
+note: required by a bound in `Option::<T>::map`
+  --> $SRC_DIR/core/src/option.rs:LL:COL
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0053, E0631.
+For more information about an error, try `rustc --explain E0053`.