Skip to content

Commit 009c561

Browse files
remove redundant requires and add TODO
1 parent bcdedb8 commit 009c561

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/core/src/ptr/non_null.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ impl<T: ?Sized> NonNull<T> {
502502
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
503503
#[stable(feature = "non_null_convenience", since = "1.80.0")]
504504
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
505-
#[requires(!origin.as_ptr().is_null())]
505+
// TODO: add a require to check whether two pointer points to the same allocated object with `same_allocation`
506506
#[ensures(
507507
|result: &isize|
508508
*result == (self.as_ptr() as *const u8).offset_from(origin.as_ptr() as *const u8)
@@ -584,7 +584,7 @@ impl<T: ?Sized> NonNull<T> {
584584
#[rustc_allow_const_fn_unstable(set_ptr_value)]
585585
#[stable(feature = "non_null_convenience", since = "1.80.0")]
586586
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
587-
#[requires(!self.as_ptr().is_null())]
587+
// TODO: add a require to check whether two pointer points to the same allocated object with `same_allocation`
588588
#[ensures(
589589
|result: &NonNull<T>|
590590
(result.as_ptr() as *const () as usize) == ((self.as_ptr() as *const () as usize) + count)
@@ -793,7 +793,7 @@ impl<T: ?Sized> NonNull<T> {
793793
#[cfg_attr(miri, track_caller)] // even without panics, this helps for Miri backtraces
794794
#[stable(feature = "non_null_convenience", since = "1.80.0")]
795795
#[rustc_const_stable(feature = "non_null_convenience", since = "1.80.0")]
796-
#[requires(!origin.as_ptr().is_null())]
796+
// TODO: add a require to check whether two pointer points to the same allocated object with `same_allocation`
797797
#[ensures(
798798
|result: &isize|
799799
*result == (self.as_ptr() as *const u8).offset_from(origin.as_ptr() as *const u8)

0 commit comments

Comments
 (0)