-
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
Poor error message related to higher rank lifetimes #37300
Comments
Its saying that your To help with reasoning why this error is reported consider an equivalent:
The types here are:
At this point compiler tries these things:
I feel like the error reported in such circumstances cannot be pointing at the right place 100% of the time, as the actual error might be either that The solution fixing the error would be to dereference the
|
ah, so I need to use the git version of tool the newest version has the correct impl, so when I do so now the issue is:
and I assume the author of tool can't fix this one because of the higher rank lifetime issue? |
Oh, so I didn’t check the issue closely enough. So… even with the change to the Changing your fn apply<A, B, C, F, G>(mut f: F, a: A)
-> impl FnMut(&B) -> C // must still be `for<'r> impl FnMut(&'r B) -> C`, because that’s what filter requires
where F: FnMut(B) -> G, // must not be `for<'r> FnMut(&'r B) -> G`, because regular functions do not implement it
G: FnMut(A) -> C,
B: Copy, // for dereferencing
A: Clone {
move |b| f(*b)(a.clone()) // this must do any bridging necessary to satisfy the requirements between filter and regular functions
} The error still (and even more so, now) seems totally correct (although kind-of opaque) to me. |
Ah, that does fix my issue. The error is correct, but I still don't understand it that well.
How would that function implement such a thing? |
I have no idea, but I have a feeling that you cannot implement traits for regular functions, so the only way to deal with the issue is to tweak bounds. |
The error message for this problem has changed to:
While this is wrong or at least incomplete, it would be at least much more comprehensible. I think this bug can be closed. The problem seems to be a duplicate of #41078. |
https://bitbucket.org/iopq/fizzbuzz-in-rust/src/6d739f4781c90be95ac47e067562471b0c52f9f8/src/lib.rs?at=error&fileviewer=file-view-default
After I try to use the tool.rs implementation of
second
I get this error message:I still don't quite understand this error message. The lifetimes are anonymous, so I don't know what it's talking about. The
'r
lifetime is elided, I assume? There's no error code to help me understand the issue with concrete lifetimes vs. bound lifetime parameters.The text was updated successfully, but these errors were encountered: