Rollup merge of #55730 - estebank:impl-trait-arg-mismatch, r=varkor

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

Fix #55374.
This commit is contained in:
kennytm 2018-11-07 18:02:04 +08:00
commit e222d1db3c
No known key found for this signature in database
GPG key ID: FEF6C8051D0E013C
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`.