Skip to content

Commit 31f858d

Browse files
committed
Auto merge of #107987 - EFanZh:inline-poll-methods, r=Mark-Simulacrum
Inline `Poll` methods With `opt-level="z"`, the `Poll::map*` methods are sometimes not inlined (see <https://godbolt.org/z/ca5ajKTEK>). This PR adds `#[inline]` to these methods. I have a project that can benefit from this change, but do we want to enable this behavior universally? Fixes #101080.
2 parents 5157d93 + 4bb0a5e commit 31f858d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: library/core/src/task/poll.rs

+5
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ impl<T> Poll<T> {
4545
/// assert_eq!(poll_some_len, Poll::Ready(13));
4646
/// ```
4747
#[stable(feature = "futures_api", since = "1.36.0")]
48+
#[inline]
4849
pub fn map<U, F>(self, f: F) -> Poll<U>
4950
where
5051
F: FnOnce(T) -> U,
@@ -144,6 +145,7 @@ impl<T, E> Poll<Result<T, E>> {
144145
/// assert_eq!(squared, Poll::Ready(Ok(144)));
145146
/// ```
146147
#[stable(feature = "futures_api", since = "1.36.0")]
148+
#[inline]
147149
pub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>>
148150
where
149151
F: FnOnce(T) -> U,
@@ -171,6 +173,7 @@ impl<T, E> Poll<Result<T, E>> {
171173
/// assert_eq!(res, Poll::Ready(Err(0)));
172174
/// ```
173175
#[stable(feature = "futures_api", since = "1.36.0")]
176+
#[inline]
174177
pub fn map_err<U, F>(self, f: F) -> Poll<Result<T, U>>
175178
where
176179
F: FnOnce(E) -> U,
@@ -199,6 +202,7 @@ impl<T, E> Poll<Option<Result<T, E>>> {
199202
/// assert_eq!(squared, Poll::Ready(Some(Ok(144))));
200203
/// ```
201204
#[stable(feature = "poll_map", since = "1.51.0")]
205+
#[inline]
202206
pub fn map_ok<U, F>(self, f: F) -> Poll<Option<Result<U, E>>>
203207
where
204208
F: FnOnce(T) -> U,
@@ -228,6 +232,7 @@ impl<T, E> Poll<Option<Result<T, E>>> {
228232
/// assert_eq!(res, Poll::Ready(Some(Err(0))));
229233
/// ```
230234
#[stable(feature = "poll_map", since = "1.51.0")]
235+
#[inline]
231236
pub fn map_err<U, F>(self, f: F) -> Poll<Option<Result<T, U>>>
232237
where
233238
F: FnOnce(E) -> U,

0 commit comments

Comments
 (0)