-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Extremely confusing error around function pointers with inferred arguments #76353
Comments
This looks like the function-pointer version of #41078 - we don't convert a 'normal' region inference variable into a higher-ranked region. See #41078 (comment) for more details |
Is this the same issue? The error fails to make any mention of lifetime struct Bar<'a>(&'a str);
impl<'a> Bar<'a> {
fn hello(&self, name: &'a str) {
println!("Hello {}!", name);
}
fn say(&self, f: fn(&Self, &str), name: &str) {
f(self, name)
}
}
fn main() {
Bar("").say(Bar::hello, "World");
} Error:
|
@camjackson no, that one's because you explicitly restricted |
I know, but the compiler error is misleading. |
Ok, can you open a separate issue for that then? This issue is about when the error isn't necessary at all, the compiler just isn't smart enough to infer the higher-ranked type. |
Current output
|
…r-errors Do not emit wrong E0308 suggestion for closure mismatch Found in rust-lang#76353.
…r-errors Do not emit wrong E0308 suggestion for closure mismatch Found in rust-lang#76353.
Consider the following code (playground):
Rustc gives an error:
Here is the fixed code (playground):
In particular, the only thing that changed was
fn(_, _)
->fn(&str, &S<'_>)
. But this is exactly the type that was printed in the diagnostic originally! What changed?I don't understand why this error was emitted, but it would at least be nice to suggest the transformation that makes the code work.
Reduced from rust-lang/crater#542.
The text was updated successfully, but these errors were encountered: