-
Notifications
You must be signed in to change notification settings - Fork 515
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
Document target_has_atomic #1171
Merged
Merged
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Would it be possible to drop the mention of
from_mut
? We generally don't cover nightly features in the reference or things that might happen in the future, or delve into the particulars of how the standard library is implemented. We don't have the capacity to track them here, and it isn't relevant to someone working on stable. Iftarget_has_atomic_equal_alignment
or something like it is stabilized in the future, then it can be added here.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.
Yeah, I have mixed feelings on this, probably should have commented on it myself. I think there's no nice way to describe what this gives you without mentioning from_mut - saying that all APIs are available would be misleading. Maybe the right thing is to drop it here and go add a note to the docs for from_mut though. It's still misleading but perhaps less so.
Does that seem like a reasonable approach?
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.
Yea, I think a mention in the
from_mut
docs sounds good. I don't know what the status or history oftarget_has_atomic_equal_alignment
is, though, so I'm not certain what the story is for stabilizingfrom_mut
.But maybe I'm misunderstanding, as I don't see how
from_mut
is important. I think it makes sense to say "it makes the corresponding APIs available". That is, if I want to write very portable code, I can write:Perhaps another way to word it would be:
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.
Getting back to this now -- the suggested text/snippet to me implies that
would also be portable, but in practice that's not the case and there's no way (on stable) to conditionally test for that method's existence. And it's pretty easy to make a mistake here, since the cfg and from_mut are true on the common platforms (IIRC, only false on i686 or so?)
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.
Since
from_mut
is still unstable, I still think it should not be mentioned in the reference. I wasn't trying to imply that every function and method would be available. Just that the primary use case fortarget_has_atomic
is to detect the presence of the types (AtomicU8, AtomicU16, …).from_mut
isn't available on stable, and I would think thattarget_has_atomic_equal_alignment
(or something similar) would be good to stabilize beforehand. And the requirement oftarget_has_atomic_equal_alignment
should be made clear in the documentation of thefrom_mut
documentation (and anything else that requires it). In theory, something like the portability lint would catch mistakes like your example.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.
@Mark-Simulacrum Just checking in again on this. I was wondering if you would be ok with removing the discussion around
from_mut
? I think that means just removing everything in the paragraph starting withwith the exception of…
. We generally avoid mentioning any unstable bits in the reference. Whenfrom_mut
and/ortarget_has_atomic_equal_alignment
is stabilized in the future, that information can be added to the reference as appropriate.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.
Oh I completely forgot about this. Yeah, I'm OK removing that for now. I'll push a commit to that effect in a moment.