summary refs log tree commit diff
path: root/src/test/ui/impl-trait
diff options
context:
space:
mode:
authorEsteban Küber <esteban@kuber.com.ar>2021-04-08 13:50:47 -0700
committerEsteban Küber <esteban@kuber.com.ar>2021-04-08 13:50:47 -0700
commit147649d4b91b43c77f3f46c04b6daaa37f4e0955 (patch)
tree84c68d5dce9babbbc0ffb1ea92e3d131fc71eed7 /src/test/ui/impl-trait
parentd43ede10e4cc69547d1c05831ca43c9902304573 (diff)
downloadrust-147649d4b91b43c77f3f46c04b6daaa37f4e0955.tar.gz
rust-147649d4b91b43c77f3f46c04b6daaa37f4e0955.zip
Suggest changing impl parameter types to match trait
This is particularly useful for cases where arbitrary self types are
used, like in custom `Future`s.
Diffstat (limited to 'src/test/ui/impl-trait')
-rw-r--r--src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr6
-rw-r--r--src/test/ui/impl-trait/trait_type.stderr5
2 files changed, 8 insertions, 3 deletions
diff --git a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr
index 638a0093fb2..d37670db085 100644
--- a/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr
+++ b/src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr
@@ -5,8 +5,10 @@ LL |     fn foo<A: Debug>(&self, a: &A, b: &impl Debug);
    |                                -- type in trait
 ...
 LL |     fn foo<B: Debug>(&self, a: &impl Debug, b: &B) { }
-   |            -                   ^^^^^^^^^^^ expected type parameter `B`, found type parameter `impl Debug`
-   |            |
+   |            -                   ^^^^^^^^^^^
+   |            |                   |
+   |            |                   expected type parameter `B`, found type parameter `impl Debug`
+   |            |                   help: change the parameter type to match the trait: `&B`
    |            expected type parameter
    |
    = note: expected fn pointer `fn(&(), &B, &impl Debug)`
diff --git a/src/test/ui/impl-trait/trait_type.stderr b/src/test/ui/impl-trait/trait_type.stderr
index 0bf43a65aa0..bea24339837 100644
--- a/src/test/ui/impl-trait/trait_type.stderr
+++ b/src/test/ui/impl-trait/trait_type.stderr
@@ -2,7 +2,10 @@ error[E0053]: method `fmt` has an incompatible type for trait
   --> $DIR/trait_type.rs:7:21
    |
 LL |    fn fmt(&self, x: &str) -> () { }
-   |                     ^^^^ types differ in mutability
+   |                     ^^^^
+   |                     |
+   |                     types differ in mutability
+   |                     help: change the parameter type to match the trait: `&mut Formatter<'_>`
    |
    = note: expected fn pointer `fn(&MyType, &mut Formatter<'_>) -> Result<(), std::fmt::Error>`
               found fn pointer `fn(&MyType, &str)`