-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
SemVer: Add section on RPIT capturing #14849
base: master
Are you sure you want to change the base?
Conversation
Not sure why.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
cc @obi1kenobi though I've already noticed obi1kenobi/cargo-semver-checks#815.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice! I look forward to being able to cite this new section in cargo-semver-checks lints :)
Thanks for the tag @weihanglo!
|
||
See the [edition guide][rpit-capture-guide] and the [reference][rpit-reference] for more information on RPIT capturing. | ||
|
||
It is a minor change to capture fewer generic parameters in an RPIT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe this might not be true for functions in non-sealed traits. If the trait's function definition changes the RPIT captures, I expect implementations of the trait have to be updated to match.
let iter = updated_crate::f(&a, &b); | ||
drop(b); // Error: cannot move out of `b` because it is borrowed | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A thought: would it be worth adding an example, or even just mentioning in a sentence or two that use<>
syntax can also be used to capture type parameters, not just lifetimes? That wasn't immediately obvious to me when I first heard about this new language feature.
This adds a section on RPIT capturing, added in Rust 1.82, with a note about how this changes in the 2024 edition.