Fix Pin::set bounds regression · patricklam/verify-rust-std@927a6da (original) (raw)

`@@ -1370,7 +1370,15 @@ impl<Ptr: Deref> Pin {

`

1370

1370

`// SAFETY: see documentation on this function

`

1371

1371

`unsafe { Pin::new_unchecked(&*self.__pointer) }

`

1372

1372

`}

`

``

1373

`+

}

`

1373

1374

``

``

1375

`` +

// These methods being in a Ptr: DerefMut impl block concerns semver stability.

``

``

1376

`` +

// Currently, calling e.g. .set() on a Pin<&T> sees that Ptr: DerefMut

``

``

1377

`` +

// doesn't hold, and goes to check for a .set() method on T. But, if the

``

``

1378

`` +

// where Ptr: DerefMut bound is moved to the method, rustc sees the impl block

``

``

1379

`+

// as a valid candidate, and doesn't go on to check other candidates when it

`

``

1380

`+

// sees that the bound on the method.

`

``

1381

`+

impl<Ptr: DerefMut> Pin {

`

1374

1382

`` /// Gets a mutable reference to the pinned value this Pin<Ptr> points to.

``

1375

1383

`///

`

1376

1384

`` /// This is a generic method to go from &mut Pin<Pointer<T>> to Pin<&mut T>.

``

`@@ -1402,10 +1410,7 @@ impl<Ptr: Deref> Pin {

`

1402

1410

```` /// ```

````

1403

1411

`#[stable(feature = "pin", since = "1.33.0")]

`

1404

1412

`#[inline(always)]

`

1405

``

`-

pub fn as_mut(&mut self) -> Pin<&mut Ptr::Target>

`

1406

``

`-

where

`

1407

``

`-

Ptr: DerefMut,

`

1408

``

`-

{

`

``

1413

`+

pub fn as_mut(&mut self) -> Pin<&mut Ptr::Target> {

`

1409

1414

`// SAFETY: see documentation on this function

`

1410

1415

`unsafe { Pin::new_unchecked(&mut *self.__pointer) }

`

1411

1416

`}

`

`@@ -1420,10 +1425,7 @@ impl<Ptr: Deref> Pin {

`

1420

1425

`#[unstable(feature = "pin_deref_mut", issue = "86918")]

`

1421

1426

`` #[must_use = "self will be dropped if the result is not used"]

``

1422

1427

`#[inline(always)]

`

1423

``

`-

pub fn as_deref_mut(self: Pin<&mut Pin>) -> Pin<&mut Ptr::Target>

`

1424

``

`-

where

`

1425

``

`-

Ptr: DerefMut,

`

1426

``

`-

{

`

``

1428

`+

pub fn as_deref_mut(self: Pin<&mut Pin>) -> Pin<&mut Ptr::Target> {

`

1427

1429

`// SAFETY: What we're asserting here is that going from

`

1428

1430

`//

`

1429

1431

`// Pin<&mut Pin>

`

`@@ -1475,12 +1477,13 @@ impl<Ptr: Deref> Pin {

`

1475

1477

`#[inline(always)]

`

1476

1478

`pub fn set(&mut self, value: Ptr::Target)

`

1477

1479

`where

`

1478

``

`-

Ptr: DerefMut,

`

1479

1480

`Ptr::Target: Sized,

`

1480

1481

`{

`

1481

1482

`*(self.__pointer) = value;

`

1482

1483

`}

`

``

1484

`+

}

`

1483

1485

``

``

1486

`+

impl<Ptr: Deref> Pin {

`

1484

1487

`` /// Unwraps this Pin<Ptr>, returning the underlying Ptr.

``

1485

1488

`///

`

1486

1489

`/// # Safety

`