-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use trait impl method span when type param mismatch is due to impl Trait
- Loading branch information
Showing
3 changed files
with
30 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |
12 changes: 12 additions & 0 deletions
12
src/test/ui/issues/type-arg-mismatch-due-to-impl-trait.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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`. |