Use trait impl method span when type param mismatch is due to impl Trait
This commit is contained in:
parent
ca4fa6f567
commit
46fcf1c6ad
3 changed files with 30 additions and 1 deletions
15
src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.rs
Normal file
15
src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.rs
Normal 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() {}
|
||||
|
|
@ -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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue