diff options
| author | bors <bors@rust-lang.org> | 2023-02-28 12:32:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-02-28 12:32:04 +0000 |
| commit | 31f858d9a511f24fedb8ed997b28304fec809630 (patch) | |
| tree | aeab8bab3ac319b66fd9b0ae63acac34fa0f59bc | |
| parent | 5157d938c49af1248a21e7ed2fbc5c6f71963276 (diff) | |
| parent | 4bb0a5ed7ff9f959c1a61f43dd796c3f18e8b260 (diff) | |
| download | rust-31f858d9a511f24fedb8ed997b28304fec809630.tar.gz rust-31f858d9a511f24fedb8ed997b28304fec809630.zip | |
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.
| -rw-r--r-- | library/core/src/task/poll.rs | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/core/src/task/poll.rs b/library/core/src/task/poll.rs index 25b61c0e666..af5bf441bb2 100644 --- a/library/core/src/task/poll.rs +++ b/library/core/src/task/poll.rs @@ -45,6 +45,7 @@ impl<T> Poll<T> { /// assert_eq!(poll_some_len, Poll::Ready(13)); /// ``` #[stable(feature = "futures_api", since = "1.36.0")] + #[inline] pub fn map<U, F>(self, f: F) -> Poll<U> where F: FnOnce(T) -> U, @@ -144,6 +145,7 @@ impl<T, E> Poll<Result<T, E>> { /// assert_eq!(squared, Poll::Ready(Ok(144))); /// ``` #[stable(feature = "futures_api", since = "1.36.0")] + #[inline] pub fn map_ok<U, F>(self, f: F) -> Poll<Result<U, E>> where F: FnOnce(T) -> U, @@ -171,6 +173,7 @@ impl<T, E> Poll<Result<T, E>> { /// assert_eq!(res, Poll::Ready(Err(0))); /// ``` #[stable(feature = "futures_api", since = "1.36.0")] + #[inline] pub fn map_err<U, F>(self, f: F) -> Poll<Result<T, U>> where F: FnOnce(E) -> U, @@ -199,6 +202,7 @@ impl<T, E> Poll<Option<Result<T, E>>> { /// assert_eq!(squared, Poll::Ready(Some(Ok(144)))); /// ``` #[stable(feature = "poll_map", since = "1.51.0")] + #[inline] pub fn map_ok<U, F>(self, f: F) -> Poll<Option<Result<U, E>>> where F: FnOnce(T) -> U, @@ -228,6 +232,7 @@ impl<T, E> Poll<Option<Result<T, E>>> { /// assert_eq!(res, Poll::Ready(Some(Err(0)))); /// ``` #[stable(feature = "poll_map", since = "1.51.0")] + #[inline] pub fn map_err<U, F>(self, f: F) -> Poll<Option<Result<T, U>>> where F: FnOnce(E) -> U, |
