-
Notifications
You must be signed in to change notification settings - Fork 12.3k
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
restate GlobalAlloc method safety preconditions in terms of what the caller has to do for greater clarity #123932
base: master
Are you sure you want to change the base?
restate GlobalAlloc method safety preconditions in terms of what the caller has to do for greater clarity #123932
Conversation
…caller has to do for greater clarity
Co-authored-by: zachs18 <8355914+zachs18@users.noreply.github.com>
@@ -221,20 +222,21 @@ pub unsafe trait GlobalAlloc { | |||
/// | |||
/// # Safety | |||
/// | |||
/// This function is unsafe because undefined behavior can result | |||
/// if the caller does not ensure all of the following: | |||
/// The caller has to ensure that |
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.
/// The caller has to ensure that | |
/// The caller must ensure that: |
@@ -157,14 +157,14 @@ pub unsafe trait GlobalAlloc { | |||
/// | |||
/// # Safety | |||
/// | |||
/// This function is unsafe because undefined behavior can result | |||
/// if the caller does not ensure all of the following: | |||
/// The caller has to ensure that |
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.
/// The caller has to ensure that | |
/// The caller must ensure that: |
must
is a bit stronger than has to
/// equal to `isize::MAX`). | ||
/// | ||
/// Otherwise undefined behaviour can result. |
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.
/// Otherwise undefined behaviour can result. | |
/// If these are not followed, undefined behaviour can result. |
Just clarify what otherwise
refers to.
/// The caller has to ensure that `layout` has non-zero size. Zero sized | ||
/// `layout` can result in undefined behaviour. |
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.
The cleanup is nice, but I don't think specifying "the caller" adds much here. Maybe something like:
/// `layout` must have non-zero size. Attempting to allocate for a zero-sized
/// `layout` may result in undefined behavior.
(optional nit)
@rustbot author Thanks for these changes, a few suggestions. Just comment |
☔ The latest upstream changes (presumably #128313) made this pull request unmergeable. Please resolve the merge conflicts. |
No description provided.