-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Trait function API mismatches (where the impl differs from the declaration) report the correct error about the mismatch, but also give a more detailed note like
= note: expected fn pointer `fn(&())`
found fn pointer `fn(())`
This could cause some confusion as the user hasn't done anything with function pointers.
trait Foo {
fn foo(&self);
}
impl Foo for () {
fn foo(self) {}
}
Errors:
Compiling playground v0.0.1 (/playground)
error[E0053]: method `foo` has an incompatible type for trait
--> src/lib.rs:6:12
|
2 | fn foo(&self);
| ----- type in trait
...
6 | fn foo(self) {}
| ^^^^ expected `&()`, found `()`
|
= note: expected fn pointer `fn(&())`
found fn pointer `fn(())`
error: aborting due to previous error
For more information about this error, try `rustc --explain E0053`.
error: could not compile `playground`.
To learn more, run the command again with --verbose.
estebank
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-bugCategory: This is a bug.Category: This is a bug.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.P-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.