From 147649d4b91b43c77f3f46c04b6daaa37f4e0955 Mon Sep 17 00:00:00 2001 From: Esteban Küber Date: Thu, 8 Apr 2021 13:50:47 -0700 Subject: 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. --- src/test/ui/impl-trait/impl-generic-mismatch-ab.stderr | 6 ++++-- src/test/ui/impl-trait/trait_type.stderr | 5 ++++- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'src/test/ui/impl-trait') 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(&self, a: &A, b: &impl Debug); | -- type in trait ... LL | fn foo(&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)` -- cgit 1.4.1-3-g733a5