-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Diagnostic refers to incorrect trait method as "fn pointer" #80929
Comments
Seems like we should just skip saying "fn pointer". Something related that's confusing: struct Foo {
bar: fn() -> i32,
}
fn bar() {}
fn main() {
Foo { bar };
}
It makes it sound like they are different in ways other than their return type, when in fact making |
I think the issue is that |
It is? Even if it is, I don't think that's what the diagnostic is saying:
IIUC, it's saying that it expected a function that takes |
I think the label does a good job of pointing out the actual problem, but I would expect the note to say something like
|
The "fn pointer" language is at rust/compiler/rustc_middle/src/ty/error.rs Line 259 in 8a65184
but I'm not immediately sure how we'd inspect it to determine whether to say "method" or "function". (The inner value is a |
I think saying
would be fine. |
I think my previous comment was wrong. As part of a Rust Awesome Mentors meeting, @MoreTacos and I tried that (changing the text to |
Mention "signature" rather than "fn pointer" when impl/trait methods are incompatible Fixes rust-lang#80929 Fixes rust-lang#67296
I tried this code (playground):
I expected to see this happen: Diagnostic mentions an expected method type and a provided method type.
Instead, this happened: Diagnostic mentions that it expected a "fn pointer" of a different type:
This was pretty confusing to me, because there are no function pointers in the code. It appears to be an implementation detail leaking through.
(There's also a typo in the
help
note which I plan to fix in a separate PR)cc #66389
Meta
rustc --version --verbose
:The text was updated successfully, but these errors were encountered: