Use trait impl method span when type param mismatch is due to impl Trait

This commit is contained in:
Esteban Küber 2018-11-06 11:24:48 -08:00
parent ca4fa6f567
commit 46fcf1c6ad
3 changed files with 30 additions and 1 deletions

View file

@ -0,0 +1,15 @@
trait Foo {
type T;
fn foo(&self, t: Self::T);
//~^ NOTE expected 0 type parameters
}
impl Foo for u32 {
type T = ();
fn foo(&self, t: impl Clone) {}
//~^ ERROR method `foo` has 1 type parameter but its trait declaration has 0 type parameters
//~| NOTE found 1 type parameter
}
fn main() {}

View file

@ -0,0 +1,12 @@
error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 type parameters
--> $DIR/type-arg-mismatch-due-to-impl-trait.rs:10:5
|
LL | fn foo(&self, t: Self::T);
| -------------------------- expected 0 type parameters
...
LL | fn foo(&self, t: impl Clone) {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found 1 type parameter
error: aborting due to previous error
For more information about this error, try `rustc --explain E0049`.