Skip to content

Commit e4f7103

Browse files
committed
[DO NOT MERGE] Use pin-project-lite in core
1 parent ce04288 commit e4f7103

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

Cargo.lock

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e"
792792
name = "core"
793793
version = "0.0.0"
794794
dependencies = [
795+
"pin-project-lite 0.2.9",
795796
"rand",
796797
"rand_xorshift",
797798
]
@@ -1429,7 +1430,7 @@ dependencies = [
14291430
"futures-sink",
14301431
"futures-task",
14311432
"memchr",
1432-
"pin-project-lite",
1433+
"pin-project-lite 0.2.8",
14331434
"pin-utils",
14341435
"slab",
14351436
]
@@ -2593,6 +2594,11 @@ version = "0.2.8"
25932594
source = "registry+https://github.com/rust-lang/crates.io-index"
25942595
checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c"
25952596

2597+
[[package]]
2598+
name = "pin-project-lite"
2599+
version = "0.2.9"
2600+
source = "git+https://github.com/taiki-e/pin-project-lite?branch=rustc-dep-of-core#50373ad4115c79de3819d72192ad5c8a6cd406fb"
2601+
25962602
[[package]]
25972603
name = "pin-utils"
25982604
version = "0.1.0"
@@ -4964,7 +4970,7 @@ dependencies = [
49644970
"autocfg",
49654971
"bytes",
49664972
"memchr",
4967-
"pin-project-lite",
4973+
"pin-project-lite 0.2.8",
49684974
]
49694975

49704976
[[package]]
@@ -4989,7 +4995,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
49894995
checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160"
49904996
dependencies = [
49914997
"cfg-if",
4992-
"pin-project-lite",
4998+
"pin-project-lite 0.2.8",
49934999
"tracing-attributes",
49945000
"tracing-core",
49955001
]

library/core/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ name = "corebenches"
2323
path = "benches/lib.rs"
2424
test = true
2525

26+
[dependencies]
27+
pin-project-lite = { git = "https://github.com/taiki-e/pin-project-lite", branch = "rustc-dep-of-core", features = ["rustc-dep-of-core"] }
28+
2629
[dev-dependencies]
2730
rand = { version = "0.8.5", default-features = false }
2831
rand_xorshift = { version = "0.3.0", default-features = false }

library/core/src/future/ready.rs

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,29 @@ use crate::future::Future;
22
use crate::pin::Pin;
33
use crate::task::{Context, Poll};
44

5-
/// A future that is immediately ready with a value.
6-
///
7-
/// This `struct` is created by [`ready()`]. See its
8-
/// documentation for more.
9-
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
10-
#[derive(Debug, Clone)]
11-
#[must_use = "futures do nothing unless you `.await` or poll them"]
12-
pub struct Ready<T>(Option<T>);
5+
pin_project_lite::pin_project! {
6+
/// A future that is immediately ready with a value.
7+
///
8+
/// This `struct` is created by [`ready()`]. See its
9+
/// documentation for more.
10+
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
11+
#[derive(Debug, Clone)]
12+
#[must_use = "futures do nothing unless you `.await` or poll them"]
13+
pub struct Ready<T> {
14+
inner: Option<T>,
15+
}
16+
}
1317

14-
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
15-
impl<T> Unpin for Ready<T> {}
18+
// #[stable(feature = "future_readiness_fns", since = "1.48.0")]
19+
// impl<T> Unpin for Ready<T> {}
1620

1721
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
1822
impl<T> Future for Ready<T> {
1923
type Output = T;
2024

2125
#[inline]
22-
fn poll(mut self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
23-
Poll::Ready(self.0.take().expect("`Ready` polled after completion"))
26+
fn poll(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<T> {
27+
Poll::Ready(self.project().inner.take().expect("`Ready` polled after completion"))
2428
}
2529
}
2630

@@ -44,7 +48,7 @@ impl<T> Ready<T> {
4448
#[must_use]
4549
#[inline]
4650
pub fn into_inner(self) -> T {
47-
self.0.expect("Called `into_inner()` on `Ready` after completion")
51+
self.inner.expect("Called `into_inner()` on `Ready` after completion")
4852
}
4953
}
5054

@@ -66,5 +70,5 @@ impl<T> Ready<T> {
6670
/// ```
6771
#[stable(feature = "future_readiness_fns", since = "1.48.0")]
6872
pub fn ready<T>(t: T) -> Ready<T> {
69-
Ready(Some(t))
73+
Ready { inner: Some(t) }
7074
}

tests/ui/proc-macro/meta-macro-hygiene.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,13 +52,13 @@ crate0::{{expn4}}: parent: crate0::{{expn3}}, call_site_ctxt: #5, def_site_ctxt:
5252
crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive")
5353
crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive")
5454
crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "include")
55-
crate2::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
55+
crate3::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
5656

5757
SyntaxContexts:
5858
#0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
5959
#1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque)
6060
#2: parent: #0, outer_mark: (crate0::{{expn1}}, Transparent)
61-
#3: parent: #0, outer_mark: (crate2::{{expn1}}, Opaque)
61+
#3: parent: #0, outer_mark: (crate3::{{expn1}}, Opaque)
6262
#4: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent)
6363
#5: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque)
6464
#6: parent: #4, outer_mark: (crate0::{{expn3}}, Transparent)

tests/ui/proc-macro/nonterminal-token-hygiene.stdout

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ crate0::{{expn4}}: parent: crate0::{{expn3}}, call_site_ctxt: #6, def_site_ctxt:
7676
crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive")
7777
crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Attr, "derive")
7878
crate1::{{expnNNN}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: Macro(Bang, "include")
79-
crate2::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
79+
crate3::{{expn1}}: parent: crate0::{{expn0}}, call_site_ctxt: #0, def_site_ctxt: #0, kind: AstPass(StdImports)
8080

8181
SyntaxContexts:
8282
#0: parent: #0, outer_mark: (crate0::{{expn0}}, Opaque)
8383
#1: parent: #0, outer_mark: (crate0::{{expn1}}, Opaque)
8484
#2: parent: #0, outer_mark: (crate0::{{expn1}}, Transparent)
85-
#3: parent: #0, outer_mark: (crate2::{{expn1}}, Opaque)
85+
#3: parent: #0, outer_mark: (crate3::{{expn1}}, Opaque)
8686
#4: parent: #0, outer_mark: (crate0::{{expn2}}, SemiTransparent)
8787
#5: parent: #0, outer_mark: (crate0::{{expn3}}, Opaque)
8888
#6: parent: #4, outer_mark: (crate0::{{expn3}}, Opaque)

0 commit comments

Comments
 (0)