Skip to content

Commit 8fa79a1

Browse files
authored
Rollup merge of rust-lang#103800 - danielhenrymantilla:stabilize-pin-macro, r=dtolnay
Stabilize `::{core,std}::pin::pin!` As discussed [over here](rust-lang#93178 (comment)), it looks like a decent time to stabilize the `pin!` macro. ### Public API ```rust // in module `core::pin` /// API: `fn pin<T>($value: T) -> Pin<&'local mut T>` pub macro pin($value:expr $(,)?) { … } ``` - Tracking issue: rust-lang#93178 (now all this needs is an FCP by the proper team?)
2 parents d4203ed + 48b7e2a commit 8fa79a1

8 files changed

+6
-17
lines changed

library/core/src/pin.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -622,9 +622,8 @@ impl<P: Deref> Pin<P> {
622622
/// that the closure is pinned.
623623
///
624624
/// The better alternative is to avoid all that trouble and do the pinning in the outer function
625-
/// instead (here using the unstable `pin` macro):
625+
/// instead (here using the [`pin!`][crate::pin::pin] macro):
626626
/// ```
627-
/// #![feature(pin_macro)]
628627
/// use std::pin::pin;
629628
/// use std::task::Context;
630629
/// use std::future::Future;
@@ -1026,7 +1025,6 @@ impl<P, U> DispatchFromDyn<Pin<U>> for Pin<P> where P: DispatchFromDyn<U> {}
10261025
/// ### Basic usage
10271026
///
10281027
/// ```rust
1029-
/// #![feature(pin_macro)]
10301028
/// # use core::marker::PhantomPinned as Foo;
10311029
/// use core::pin::{pin, Pin};
10321030
///
@@ -1044,7 +1042,6 @@ impl<P, U> DispatchFromDyn<Pin<U>> for Pin<P> where P: DispatchFromDyn<U> {}
10441042
/// ### Manually polling a `Future` (without `Unpin` bounds)
10451043
///
10461044
/// ```rust
1047-
/// #![feature(pin_macro)]
10481045
/// use std::{
10491046
/// future::Future,
10501047
/// pin::pin,
@@ -1083,7 +1080,7 @@ impl<P, U> DispatchFromDyn<Pin<U>> for Pin<P> where P: DispatchFromDyn<U> {}
10831080
/// ### With `Generator`s
10841081
///
10851082
/// ```rust
1086-
/// #![feature(generators, generator_trait, pin_macro)]
1083+
/// #![feature(generators, generator_trait)]
10871084
/// use core::{
10881085
/// ops::{Generator, GeneratorState},
10891086
/// pin::pin,
@@ -1126,7 +1123,6 @@ impl<P, U> DispatchFromDyn<Pin<U>> for Pin<P> where P: DispatchFromDyn<U> {}
11261123
/// The following, for instance, fails to compile:
11271124
///
11281125
/// ```rust,compile_fail
1129-
/// #![feature(pin_macro)]
11301126
/// use core::pin::{pin, Pin};
11311127
/// # use core::{marker::PhantomPinned as Foo, mem::drop as stuff};
11321128
///
@@ -1168,7 +1164,7 @@ impl<P, U> DispatchFromDyn<Pin<U>> for Pin<P> where P: DispatchFromDyn<U> {}
11681164
/// constructor.
11691165
///
11701166
/// [`Box::pin`]: ../../std/boxed/struct.Box.html#method.pin
1171-
#[unstable(feature = "pin_macro", issue = "93178")]
1167+
#[stable(feature = "pin_macro", since = "CURRENT_RUSTC_VERSION")]
11721168
#[rustc_macro_transparency = "semitransparent"]
11731169
#[allow_internal_unstable(unsafe_pin_internals)]
11741170
pub macro pin($value:expr $(,)?) {

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@
4848
#![feature(is_sorted)]
4949
#![feature(layout_for_ptr)]
5050
#![feature(pattern)]
51-
#![feature(pin_macro)]
5251
#![feature(sort_internals)]
5352
#![feature(slice_take)]
5453
#![feature(slice_from_ptr_range)]

src/tools/miri/tests/pass/issues/issue-miri-2068.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(pin_macro)]
2-
31
use core::future::Future;
42
use core::pin::Pin;
53
use core::task::{Context, Poll};

src/tools/miri/tests/pass/stacked-borrows/future-self-referential.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#![feature(pin_macro)]
2-
31
use std::future::*;
42
use std::marker::PhantomPinned;
53
use std::pin::*;

tests/ui/pin-macro/cant_access_internals.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// edition:2018
2-
#![feature(pin_macro)]
32

43
use core::{
54
marker::PhantomPinned,

tests/ui/pin-macro/cant_access_internals.stderr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0658]: use of unstable library feature 'unsafe_pin_internals'
2-
--> $DIR/cant_access_internals.rs:12:15
2+
--> $DIR/cant_access_internals.rs:11:15
33
|
44
LL | mem::take(phantom_pinned.pointer);
55
| ^^^^^^^^^^^^^^^^^^^^^^

tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// edition:2018
2-
#![feature(pin_macro)]
32

43
use core::{
54
convert::identity,

tests/ui/pin-macro/lifetime_errors_on_promotion_misusage.stderr

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0716]: temporary value dropped while borrowed
2-
--> $DIR/lifetime_errors_on_promotion_misusage.rs:12:35
2+
--> $DIR/lifetime_errors_on_promotion_misusage.rs:11:35
33
|
44
LL | let phantom_pinned = identity(pin!(PhantomPinned));
55
| ^^^^^^^^^^^^^^^^^^^ - temporary value is freed at the end of this statement
@@ -13,7 +13,7 @@ LL | stuff(phantom_pinned)
1313
= note: this error originates in the macro `pin` (in Nightly builds, run with -Z macro-backtrace for more info)
1414

1515
error[E0716]: temporary value dropped while borrowed
16-
--> $DIR/lifetime_errors_on_promotion_misusage.rs:19:30
16+
--> $DIR/lifetime_errors_on_promotion_misusage.rs:18:30
1717
|
1818
LL | let phantom_pinned = {
1919
| -------------- borrow later stored here

0 commit comments

Comments
 (0)