@@ -1370,7 +1370,15 @@ impl<Ptr: Deref> Pin<Ptr> {
13701370 // SAFETY: see documentation on this function
13711371 unsafe { Pin :: new_unchecked ( & * self . __pointer ) }
13721372 }
1373+ }
13731374
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 < Ptr > {
13741382 /// Gets a mutable reference to the pinned value this `Pin<Ptr>` points to.
13751383 ///
13761384 /// This is a generic method to go from `&mut Pin<Pointer<T>>` to `Pin<&mut T>`.
@@ -1402,10 +1410,7 @@ impl<Ptr: Deref> Pin<Ptr> {
14021410 /// ```
14031411 #[ stable( feature = "pin" , since = "1.33.0" ) ]
14041412 #[ 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 > {
14091414 // SAFETY: see documentation on this function
14101415 unsafe { Pin :: new_unchecked ( & mut * self . __pointer ) }
14111416 }
@@ -1420,10 +1425,7 @@ impl<Ptr: Deref> Pin<Ptr> {
14201425 #[ unstable( feature = "pin_deref_mut" , issue = "86918" ) ]
14211426 #[ must_use = "`self` will be dropped if the result is not used" ]
14221427 #[ inline( always) ]
1423- pub fn as_deref_mut ( self : Pin < & mut Pin < Ptr > > ) -> Pin < & mut Ptr :: Target >
1424- where
1425- Ptr : DerefMut ,
1426- {
1428+ pub fn as_deref_mut ( self : Pin < & mut Pin < Ptr > > ) -> Pin < & mut Ptr :: Target > {
14271429 // SAFETY: What we're asserting here is that going from
14281430 //
14291431 // Pin<&mut Pin<Ptr>>
@@ -1475,12 +1477,13 @@ impl<Ptr: Deref> Pin<Ptr> {
14751477 #[ inline( always) ]
14761478 pub fn set ( & mut self , value : Ptr :: Target )
14771479 where
1478- Ptr : DerefMut ,
14791480 Ptr :: Target : Sized ,
14801481 {
14811482 * ( self . __pointer ) = value;
14821483 }
1484+ }
14831485
1486+ impl < Ptr : Deref > Pin < Ptr > {
14841487 /// Unwraps this `Pin<Ptr>`, returning the underlying `Ptr`.
14851488 ///
14861489 /// # Safety
0 commit comments