-
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
Rejecting higher-kinded lifetime bounds is a breaking change #50555
Comments
This is in the 1.26 that's about to ship, right? Maybe it should be mentioned in the release notes? I don't think it's too far of a stretch to say that there is live code out there with a |
For the record, I reported this after running into it with real code I was developing on stable. I needed to debug a macro, so I switched to nightly in order to use |
Yes it is a breaking change indeed, introduced in #48326. That's why we did a crater run, which came back with a single failure. However, @comex your code is equivalent to fn foo<'s, F>(s: &'s i32, f: F) where for<'a> F: FnOnce(&'a i32) {
...
} That is, the bound you wrote is entirely ignored. So, this only breaks code that already did not do what the author thought it would. Given that so far, not many people seem to have made this mistake (writing lifetime bounds that are ignored), it seemed worth the breaking change to make sure no more people will do so in the future. |
Welp, I didn't realize we were so close to a stable release containing the change in question. I guess this is now moot. But I wish the change had gone through a warning cycle. |
U cannot get this to work. It's close but I think it requires lifetime bounds on the HRTB lifetimes e.g. `F: for<'a, 'store: 'a> ...`, which currently isn't possible (seems to have been possible at one point? rust-lang/rust#50555 Could also be just that the syntax didn't result in an error, but had no semantic meaning attached to it.)
U cannot get this to work. It's close but I think it requires lifetime bounds on the HRTB lifetimes e.g. `F: for<'a, 'store: 'a> ...`, which currently isn't possible (seems to have been possible at one point? rust-lang/rust#50555 Could also be just that the syntax didn't result in an error, but had no semantic meaning attached to it.)
Apologies for resurrecting an old issue; I find myself in need of Is this a false impression, was it just that the syntax didn't trigger an error, but no semantics were attached to it? Or was this indeed a working feature that was removed (presumably for soundness reasons)? |
That was indeed the case. The bound got parsed, and then ignored. |
Playground Link
This compiles on stable; on beta and above, it produces:
Apparently this is on purpose:
But it's still a gratuitous breaking change, which seems unfortunate… even if the lifetimes weren't being handled correctly before.
cc @RalfJung
The text was updated successfully, but these errors were encountered: