-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
undocumented lifetime elision fix from 1.15 -> 1.16 ? #41105
Comments
Can you provide a small example? |
Unfortunately I don't have time right now. Compiling goblin 0.0.9 with 1.15 and 1.16 illustrates the issue. I suspect it's related to closures so a simple lifetime based struct + a closure may illustrate but I don't know |
cc @rust-lang/core -- should we add a note (and possibly backport?) to the 1.16 release notes? |
This is certainly a result of #39305, or at least that suite of changes. As part of that, @eddyb made expansion within function bodies more likely to use inference variables, and hence more accepting -- and I suspect that is why this code is being accepted now. I think a compatibility note (or feature note, depending on your POV) would make sense. Something like:
|
I'm going to denominate and tag with E-easy. We should add the note to master's release notes in version 1.16, but I don't think we should bother backporting. |
…ichton RELEASES.md: document 1.16 lifetime elision change Closes rust-lang#41105. r? @Mark-Simulacrum cc @nikomatsakis
Specifically, this line of code failed to compile on 1.15.1, but successfully compiles on 1.16: https://github.com/m4b/goblin/blob/8188a8a15017cbdadfdbb807e08db968f1c634c9/src/mach/exports.rs#L94
For context, here is the important snippet:
So, the fix (for 1.15) is adding explicit lifetime annotation to the closure return (e.g.,
let reexport = |mut offset| -> error::Result<ExportInfo<'a>>{..}
)Consequently, it seems that this is an undocumented lifetime elision fix, or substantially less likely, 1.16 incorrectly compiles invalid lifetime code in closures.
I suspect its the former.
So, I dunno why, maybe I'm being an alarmist, but I find this somewhat serious, and fairly annoying; the only reason I upgraded to 1.16 was that I wanted
cargo check
for development, but upstream projects using my crate use 1.15 for CI, recommended version, etc; consequently, when 1.16 was released I noted that there were no major compiler fixes in this cycle, or major issues in compatibility notes, etc., which would cause a difference between a client compiling on 1.15 versus 1.16, so it should be safe to develop on 1.16 stable for cargo check; but alas, this is not the case.The text was updated successfully, but these errors were encountered: