-
Notifications
You must be signed in to change notification settings - Fork 1
Adds contracts for byte_add, byte_sub and byte_offset #19
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
Conversation
- Also adds proofs verifying unit, int and composite types.
library/core/src/ptr/mut_ptr.rs
Outdated
#[cfg_attr( | ||
bootstrap, | ||
rustc_const_stable(feature = "ptr_metadata_const", since = "1.83.0") | ||
)] |
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 rustfmt formatting is unnecessary
library/core/src/ptr/mut_ptr.rs
Outdated
@@ -277,7 +285,11 @@ impl<T: ?Sized> *mut T { | |||
pub const unsafe fn as_ref<'a>(self) -> Option<&'a T> { | |||
// SAFETY: the caller must guarantee that `self` is valid for a | |||
// reference if it isn't null. | |||
if self.is_null() { None } else { unsafe { Some(&*self) } } | |||
if self.is_null() { |
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 rustfmt formatting is unnecessary
library/core/src/ptr/mut_ptr.rs
Outdated
@@ -352,7 +364,11 @@ impl<T: ?Sized> *mut T { | |||
{ | |||
// SAFETY: the caller must guarantee that `self` meets all the | |||
// requirements for a reference. | |||
if self.is_null() { None } else { Some(unsafe { &*(self as *const MaybeUninit<T>) }) } | |||
if self.is_null() { |
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 rustfmt formatting is unnecessary
library/core/src/ptr/mut_ptr.rs
Outdated
@@ -537,7 +569,9 @@ impl<T: ?Sized> *mut T { | |||
#[stable(feature = "pointer_byte_offsets", since = "1.75.0")] | |||
#[rustc_const_stable(feature = "const_pointer_byte_offsets", since = "1.75.0")] | |||
pub const fn wrapping_byte_offset(self, count: isize) -> Self { | |||
self.cast::<u8>().wrapping_offset(count).with_metadata_of(self) | |||
self.cast::<u8>() |
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 rustfmt formatting is unnecessary
library/core/src/ptr/mut_ptr.rs
Outdated
@@ -578,7 +612,9 @@ impl<T: ?Sized> *mut T { | |||
#[must_use = "returns a new pointer rather than modifying its argument"] | |||
#[inline(always)] | |||
pub fn mask(self, mask: usize) -> *mut T { | |||
intrinsics::ptr_mask(self.cast::<()>(), mask).cast_mut().with_metadata_of(self) | |||
intrinsics::ptr_mask(self.cast::<()>(), mask) |
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 rustfmt formatting is unnecessary
library/core/src/ptr/mut_ptr.rs
Outdated
@@ -628,7 +664,11 @@ impl<T: ?Sized> *mut T { | |||
pub const unsafe fn as_mut<'a>(self) -> Option<&'a mut T> { | |||
// SAFETY: the caller must guarantee that `self` is be valid for | |||
// a mutable reference if it isn't null. | |||
if self.is_null() { None } else { unsafe { Some(&mut *self) } } | |||
if self.is_null() { |
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 rustfmt formatting is unnecessary
library/core/src/ptr/mut_ptr.rs
Outdated
@@ -689,7 +729,11 @@ impl<T: ?Sized> *mut T { | |||
{ | |||
// SAFETY: the caller must guarantee that `self` meets all the | |||
// requirements for a reference. | |||
if self.is_null() { None } else { Some(unsafe { &mut *(self as *mut MaybeUninit<T>) }) } | |||
if self.is_null() { |
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 rustfmt formatting is unnecessary
- Adds harnesses for int, unit, composite and slice types
Resolves #ISSUE-NUMBER
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.