Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a missing test case for impl generic mismatch #100945

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/test/ui/impl-trait/impl-generic-mismatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ impl Bar for () {
//~^ Error method `bar` has incompatible signature for trait
}

trait Baz {
fn baz<U: Debug, T: Debug>(&self, _: &U, _: &T);
}

impl Baz for () {
fn baz<T: Debug>(&self, _: &impl Debug, _: &T) { }
//~^ Error method `baz` has incompatible signature for trait
}

// With non-local trait (#49841):

use std::hash::{Hash, Hasher};
Expand Down
18 changes: 16 additions & 2 deletions src/test/ui/impl-trait/impl-generic-mismatch.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,22 @@ help: try changing the `impl Trait` argument to a generic parameter
LL | fn bar<U: Debug>(&self, _: &U) { }
| ++++++++++ ~

error[E0643]: method `baz` has incompatible signature for trait
--> $DIR/impl-generic-mismatch.rs:26:33
|
LL | fn baz<U: Debug, T: Debug>(&self, _: &U, _: &T);
| - declaration in trait here
...
LL | fn baz<T: Debug>(&self, _: &impl Debug, _: &T) { }
| ^^^^^^^^^^ expected generic parameter, found `impl Trait`
|
help: try changing the `impl Trait` argument to a generic parameter
|
LL | fn baz<U: Debug, T: Debug>(&self, _: &T, _: &T) { }
| ~~~~~~~~~~~~~~~~~~~~ ~

error[E0643]: method `hash` has incompatible signature for trait
--> $DIR/impl-generic-mismatch.rs:28:33
--> $DIR/impl-generic-mismatch.rs:37:33
|
LL | fn hash(&self, hasher: &mut impl Hasher) {}
| ^^^^^^^^^^^ expected generic parameter, found `impl Trait`
Expand All @@ -38,6 +52,6 @@ LL | fn hash(&self, hasher: &mut impl Hasher) {}
LL | fn hash<H: Hasher>(&self, state: &mut H);
| - declaration in trait here

error: aborting due to 3 previous errors
error: aborting due to 4 previous errors

For more information about this error, try `rustc --explain E0643`.