Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

veluca93
Copy link

@veluca93 veluca93 commented Jan 24, 2025

Tracking issue: rust-lang/rust#69098
Stabilization proposal: rust-lang/rust#134090

@rustbot rustbot added the S-waiting-on-review Status: The marked PR is awaiting review from a maintainer label Jan 24, 2025
@ehuss
Copy link
Contributor

ehuss commented Jan 24, 2025

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.

@veluca93
Copy link
Author

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 :-)

Copy link
Contributor

@chorman0773 chorman0773 left a 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.

Comment on lines 92 to 94
- `#[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.
Copy link
Contributor

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?

Copy link
Author

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?

Copy link
Contributor

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.

@ehuss
Copy link
Contributor

ehuss commented Feb 6, 2025

Am I correct in understanding that this is a new "unsafe superpower"? That is, do we need to add a new item to unsafety.md that defines something along the lines of calling a safe function with an unmatched target_feature?

@veluca93
Copy link
Author

veluca93 commented Feb 6, 2025

Am I correct in understanding that this is a new "unsafe superpower"? That is, do we need to add a new item to unsafety.md that defines something along the lines of calling a safe function with an unmatched target_feature?

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)

ehuss added 4 commits February 6, 2025 19:27
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: The marked PR is awaiting review from a maintainer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants