Point at individual type arguments on arg count mismatch

This commit is contained in:
Esteban Küber 2019-06-01 10:35:31 -07:00
parent 8e595f5610
commit 28859472f7
6 changed files with 76 additions and 29 deletions

View file

@ -8,5 +8,15 @@ impl Foo for Bar {
fn foo(x: bool) -> Self { Bar } //~ ERROR E0049
}
trait Fuzz {
fn fuzz<A: Default, B>(x: A, y: B) -> Self;
}
struct Baz;
impl Fuzz for Baz {
fn fuzz(x: bool, y: bool) -> Self { Baz } //~ ERROR E0049
}
fn main() {
}

View file

@ -1,12 +1,23 @@
error[E0049]: method `foo` has 0 type parameters but its trait declaration has 1 type parameter
--> $DIR/E0049.rs:8:5
--> $DIR/E0049.rs:8:11
|
LL | fn foo<T: Default>(x: T) -> Self;
| --------------------------------- expected 1 type parameter
| - expected 1 type parameter
...
LL | fn foo(x: bool) -> Self { Bar }
| ^^^^^^^^^^^^^^^^^^^^^^^ found 0 type parameters
| ^ found 0 type parameters
error: aborting due to previous error
error[E0049]: method `fuzz` has 0 type parameters but its trait declaration has 2 type parameters
--> $DIR/E0049.rs:18:12
|
LL | fn fuzz<A: Default, B>(x: A, y: B) -> Self;
| - -
| |
| expected 2 type parameters
...
LL | fn fuzz(x: bool, y: bool) -> Self { Baz }
| ^ found 0 type parameters
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0049`.

View file

@ -1,8 +1,8 @@
error[E0049]: method `foo` has 1 type parameter but its trait declaration has 0 type parameters
--> $DIR/issue-36708.rs:8:11
--> $DIR/issue-36708.rs:8:12
|
LL | fn foo<T>() {}
| ^^^ found 1 type parameter, expected 0
| ^ found 1 type parameter, expected 0
error: aborting due to previous error

View file

@ -1,11 +1,11 @@
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:11
--> $DIR/type-arg-mismatch-due-to-impl-trait.rs:10:22
|
LL | fn foo(&self, t: Self::T);
| -------------------------- expected 0 type parameters
| - expected 0 type parameters
...
LL | fn foo(&self, t: impl Clone) {}
| ^ found 1 type parameter
| ^^^^^^^^^^ found 1 type parameter
error: aborting due to previous error