Skip to content

Commit 06def89

Browse files
committed
Fix Pin::set bounds regression
1 parent c6db1ca commit 06def89

File tree

1 file changed

+27
-26
lines changed

1 file changed

+27
-26
lines changed

library/core/src/pin.rs

+27-26
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,33 @@ impl<Ptr: Deref> Pin<Ptr> {
14511451
unsafe { self.get_unchecked_mut() }.as_mut()
14521452
}
14531453

1454+
/// Unwraps this `Pin<Ptr>`, returning the underlying `Ptr`.
1455+
///
1456+
/// # Safety
1457+
///
1458+
/// This function is unsafe. You must guarantee that you will continue to
1459+
/// treat the pointer `Ptr` as pinned after you call this function, so that
1460+
/// the invariants on the `Pin` type can be upheld. If the code using the
1461+
/// resulting `Ptr` does not continue to maintain the pinning invariants that
1462+
/// is a violation of the API contract and may lead to undefined behavior in
1463+
/// later (safe) operations.
1464+
///
1465+
/// Note that you must be able to guarantee that the data pointed to by `Ptr`
1466+
/// will be treated as pinned all the way until its `drop` handler is complete!
1467+
///
1468+
/// *For more information, see the [`pin` module docs][self]*
1469+
///
1470+
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
1471+
/// instead.
1472+
#[inline(always)]
1473+
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1474+
#[stable(feature = "pin_into_inner", since = "1.39.0")]
1475+
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
1476+
pin.__pointer
1477+
}
1478+
}
1479+
1480+
impl<Ptr: DerefMut> Pin<Ptr> {
14541481
/// Assigns a new value to the memory location pointed to by the `Pin<Ptr>`.
14551482
///
14561483
/// This overwrites pinned data, but that is okay: the original pinned value's destructor gets
@@ -1475,36 +1502,10 @@ impl<Ptr: Deref> Pin<Ptr> {
14751502
#[inline(always)]
14761503
pub fn set(&mut self, value: Ptr::Target)
14771504
where
1478-
Ptr: DerefMut,
14791505
Ptr::Target: Sized,
14801506
{
14811507
*(self.__pointer) = value;
14821508
}
1483-
1484-
/// Unwraps this `Pin<Ptr>`, returning the underlying `Ptr`.
1485-
///
1486-
/// # Safety
1487-
///
1488-
/// This function is unsafe. You must guarantee that you will continue to
1489-
/// treat the pointer `Ptr` as pinned after you call this function, so that
1490-
/// the invariants on the `Pin` type can be upheld. If the code using the
1491-
/// resulting `Ptr` does not continue to maintain the pinning invariants that
1492-
/// is a violation of the API contract and may lead to undefined behavior in
1493-
/// later (safe) operations.
1494-
///
1495-
/// Note that you must be able to guarantee that the data pointed to by `Ptr`
1496-
/// will be treated as pinned all the way until its `drop` handler is complete!
1497-
///
1498-
/// *For more information, see the [`pin` module docs][self]*
1499-
///
1500-
/// If the underlying data is [`Unpin`], [`Pin::into_inner`] should be used
1501-
/// instead.
1502-
#[inline(always)]
1503-
#[rustc_const_unstable(feature = "const_pin", issue = "76654")]
1504-
#[stable(feature = "pin_into_inner", since = "1.39.0")]
1505-
pub const unsafe fn into_inner_unchecked(pin: Pin<Ptr>) -> Ptr {
1506-
pin.__pointer
1507-
}
15081509
}
15091510

15101511
impl<'a, T: ?Sized> Pin<&'a T> {

0 commit comments

Comments
 (0)