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:
commit
e222d1db3c
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