-
Notifications
You must be signed in to change notification settings - Fork 508
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
Update reference for target_feature_11. #1720
base: master
Are you sure you want to change the base?
Conversation
Note there was a previous PR at #1181 that includes some comments of things that were missing or confusing. For example #1181 (comment), contained some changes that happened over time that hadn't yet been captured. |
I was not aware of the existing PR! I believe I have integrated the main comments from that PR, PTAL :-) |
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.
Content looks to be correct (verified by short code tests) and I don't have any editorial concerns.
src/attributes/codegen.md
Outdated
- `#[target_feature]` functions (and closures that inherit the attribute) | ||
can only be safely called within caller that enable all the `target_feature`s | ||
that the callee enables. |
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.
Does this still exclude implicitly enabled features? If so, can this be clarified to state that it is only the explicitly listed features from the attribute on both sides, and does not consider implicit ones?
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.
This does include implicitly enabled features on either side.
Although of course implicitly enabled features on the callee are enabled on the caller too if all the explicitly enabled features in the callee are enabled...
Do you think that is something that should be clarified?
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.
Ah, ok. It looks like this changed in rust-lang/rust#128221 since the last time I looked at this.
I'd like to do a quick editorial pass, and I'll try to clarify this point. I'll try to get to that today.
Am I correct in understanding that this is a new "unsafe superpower"? That is, do we need to add a new item to |
I think this is technically true, yes (in some sense it is not new, because tf functions were unsafe before, but it's probably worth mentioning explicitly) |
The `unsafe` block enables several abilities beyond just calling unsafe functions and dereferencing pointers. Link to the actual list of things you can do.
This does some rewording to try to make things a little more explicit and clearer: - Moves the `Fn` traits to a separate rule, it wasn't directly related to what is safe and not safe. - Moves the allowed positions into a separate rule, and adds some links to those. I dropped the "other special functions" because it is not defined anywhere. - Add an example. - Add a remark about implicit features. - Don't say "on many platforms", and be more explicit about how this is overridden. - Various rewording for clarity. - Remove word wrapping.
Tracking issue: rust-lang/rust#69098
Stabilization proposal: rust-lang/rust#134090