From 56704d424c8dd6e74b516c3c616ff59f74c863c2 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 4 Sep 2024 16:03:47 -0700 Subject: [PATCH 1/2] Begin experimental support for pin reborrowing This commit adds basic support for reborrowing `Pin` types in argument position. At the moment it only supports reborrowing `Pin<&mut T>` as `Pin<&mut T>` by inserting a call to `Pin::as_mut()`, and only in argument position (not as the receiver in a method call). --- core/src/pin.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/pin.rs b/core/src/pin.rs index 9c13662e08e8f..bb1196e82de78 100644 --- a/core/src/pin.rs +++ b/core/src/pin.rs @@ -1408,6 +1408,7 @@ impl Pin { /// } /// } /// ``` + #[cfg_attr(not(bootstrap), lang = "pin_as_mut")] #[stable(feature = "pin", since = "1.33.0")] #[inline(always)] pub fn as_mut(&mut self) -> Pin<&mut Ptr::Target> { From 7b1c5e87b84d24cb46b439db26b345d376442255 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Thu, 19 Sep 2024 11:18:00 -0700 Subject: [PATCH 2/2] Allow shortening reborrows Generating a call to `as_mut()` let to more restrictive borrows than what reborrowing usually gives us. Instead, we change the desugaring to reborrow the pin internals directly which makes things more expressive. --- core/src/pin.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/core/src/pin.rs b/core/src/pin.rs index bb1196e82de78..9c13662e08e8f 100644 --- a/core/src/pin.rs +++ b/core/src/pin.rs @@ -1408,7 +1408,6 @@ impl Pin { /// } /// } /// ``` - #[cfg_attr(not(bootstrap), lang = "pin_as_mut")] #[stable(feature = "pin", since = "1.33.0")] #[inline(always)] pub fn as_mut(&mut self) -> Pin<&mut Ptr::Target> {