Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide map_ok and map_err method for Poll<Option<Result<T, E>>> #63512

Merged
merged 1 commit into from Aug 14, 2019

Conversation

@95th
Copy link
Contributor

commented Aug 13, 2019

Currently map_ok and map_err methods are given for Poll<Result<T, E>>.

This PR adds these methods for Poll<Option<Result<T, E>>> as they are helpful in stream building code.

@rust-highfive

This comment was marked as outdated.

Copy link
Collaborator

commented Aug 13, 2019

r? @TimNN

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Aug 13, 2019

The job mingw-check of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-08-13T07:51:58.8444493Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-13T07:51:59.7806996Z ##[command]git config gc.auto 0
2019-08-13T07:51:59.7813758Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-13T07:51:59.7815946Z ##[command]git config --get-all http.proxy
2019-08-13T07:51:59.7820758Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63512/merge:refs/remotes/pull/63512/merge
---
2019-08-13T07:52:36.3385597Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-13T07:52:36.3385698Z 
2019-08-13T07:52:36.3386055Z   git checkout -b <new-branch-name>
2019-08-13T07:52:36.3386086Z 
2019-08-13T07:52:36.3386154Z HEAD is now at f6523ad5f Merge 5be725f94ea68f3365d3c4d56b0bfb9af57a9bda into 60960a260f7b5c695fd0717311d72ce62dd4eb43
2019-08-13T07:52:36.3547982Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-13T07:52:36.3551553Z ==============================================================================
2019-08-13T07:52:36.3551701Z Task         : Bash
2019-08-13T07:52:36.3551754Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-13T07:57:29.5289706Z 76 | #![feature(const_generics)]
2019-08-13T07:57:29.5301927Z    |            ^^^^^^^^^^^^^^
2019-08-13T07:57:29.5304390Z 
2019-08-13T07:57:37.7226616Z error[E0308]: mismatched types
2019-08-13T07:57:37.7232157Z   --> src/libcore/task/poll.rs:90:53
2019-08-13T07:57:37.7237530Z    |
2019-08-13T07:57:37.7243150Z 90 |             Poll::Ready(Some(Ok(t))) => Poll::Ready(Some(Ok(f(t)))),
2019-08-13T07:57:37.7250184Z    |                                                     ^^^^^^^^^^^^^^ expected enum `result::Result`, found enum `option::Option`
2019-08-13T07:57:37.7252475Z    |
2019-08-13T07:57:37.7305888Z    = note: expected type `result::Result<_, E>`
2019-08-13T07:57:37.7306945Z               found type `option::Option<result::Result<_, _>>`
2019-08-13T07:57:37.7331617Z error[E0308]: mismatched types
2019-08-13T07:57:37.7331617Z error[E0308]: mismatched types
2019-08-13T07:57:37.7336133Z   --> src/libcore/task/poll.rs:91:54
2019-08-13T07:57:37.7339513Z    |
2019-08-13T07:57:37.7343331Z 91 |             Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(e))),
2019-08-13T07:57:37.7348984Z    |                                                      ^^^^^^^^^^^^ expected enum `result::Result`, found enum `option::Option`
2019-08-13T07:57:37.7349649Z    |
2019-08-13T07:57:37.7353738Z    = note: expected type `result::Result<U, _>`
2019-08-13T07:57:37.7377634Z               found type `option::Option<result::Result<_, _>>`
2019-08-13T07:57:37.7436859Z error[E0308]: mismatched types
2019-08-13T07:57:37.7436859Z error[E0308]: mismatched types
2019-08-13T07:57:37.7440475Z   --> src/libcore/task/poll.rs:92:46
2019-08-13T07:57:37.7444091Z    |
2019-08-13T07:57:37.7449163Z 92 |             Poll::Ready(None) => Poll::Ready(None),
2019-08-13T07:57:37.7452564Z    |                                              ^^^^ expected enum `result::Result`, found enum `option::Option`
2019-08-13T07:57:37.7457245Z    |
2019-08-13T07:57:37.7460072Z    = note: expected type `result::Result<U, E>`
2019-08-13T07:57:37.7462824Z               found type `option::Option<_>`
2019-08-13T07:57:37.7567593Z error[E0308]: mismatched types
2019-08-13T07:57:37.7567593Z error[E0308]: mismatched types
2019-08-13T07:57:37.7571165Z    --> src/libcore/task/poll.rs:102:53
2019-08-13T07:57:37.7575450Z     |
2019-08-13T07:57:37.7579727Z 102 |             Poll::Ready(Some(Ok(t))) => Poll::Ready(Some(Ok(t))),
2019-08-13T07:57:37.7624815Z     |                                                     ^^^^^^^^^^^ expected enum `result::Result`, found enum `option::Option`
2019-08-13T07:57:37.7626884Z     |
2019-08-13T07:57:37.7627218Z     = note: expected type `result::Result<_, U>`
2019-08-13T07:57:37.7627550Z                found type `option::Option<result::Result<_, _>>`
2019-08-13T07:57:37.7675325Z error[E0308]: mismatched types
2019-08-13T07:57:37.7675325Z error[E0308]: mismatched types
2019-08-13T07:57:37.7679921Z    --> src/libcore/task/poll.rs:103:54
2019-08-13T07:57:37.7683593Z     |
2019-08-13T07:57:37.7688067Z 103 |             Poll::Ready(Some(Err(e))) => Poll::Ready(Some(Err(f(e)))),
2019-08-13T07:57:37.7741750Z     |                                                      ^^^^^^^^^^^^^^^ expected enum `result::Result`, found enum `option::Option`
2019-08-13T07:57:37.7742451Z     = note: expected type `result::Result<T, _>`
2019-08-13T07:57:37.7742451Z     = note: expected type `result::Result<T, _>`
2019-08-13T07:57:37.7742785Z                found type `option::Option<result::Result<_, _>>`
2019-08-13T07:57:37.7762804Z error[E0308]: mismatched types
2019-08-13T07:57:37.7762804Z error[E0308]: mismatched types
2019-08-13T07:57:37.7769859Z    --> src/libcore/task/poll.rs:104:46
2019-08-13T07:57:37.7823531Z     |
2019-08-13T07:57:37.7823866Z 104 |             Poll::Ready(None) => Poll::Ready(None),
2019-08-13T07:57:37.7824262Z     |                                              ^^^^ expected enum `result::Result`, found enum `option::Option`
2019-08-13T07:57:37.7825782Z     = note: expected type `result::Result<T, U>`
2019-08-13T07:57:37.7826064Z                found type `option::Option<_>`
2019-08-13T07:57:37.7826102Z 
2019-08-13T07:57:38.0085502Z    Compiling libc v0.2.60
---
2019-08-13T07:57:40.2907104Z For more information about this error, try `rustc --explain E0308`.
2019-08-13T07:57:40.3940121Z error: Could not compile `core`.
2019-08-13T07:57:40.3959247Z warning: build failed, waiting for other jobs to finish...
2019-08-13T07:57:40.7881263Z error: build failed
2019-08-13T07:57:40.7922125Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
2019-08-13T07:57:40.7935057Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
2019-08-13T07:57:40.7935321Z Build completed unsuccessfully in 0:02:16
2019-08-13T07:57:40.7935321Z Build completed unsuccessfully in 0:02:16
2019-08-13T07:57:54.0764032Z ##[error]Bash exited with code '1'.
2019-08-13T07:57:54.0806103Z ##[section]Starting: Checkout
2019-08-13T07:57:54.0813263Z ==============================================================================
2019-08-13T07:57:54.0813350Z Task         : Get sources
2019-08-13T07:57:54.0813403Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@rust-highfive

This comment was marked as resolved.

Copy link
Collaborator

commented Aug 13, 2019

The job mingw-check of your PR failed (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
2019-08-13T08:00:52.4676579Z ##[command]git remote add origin https://github.com/rust-lang/rust
2019-08-13T08:00:52.4846095Z ##[command]git config gc.auto 0
2019-08-13T08:00:52.4917683Z ##[command]git config --get-all http.https://github.com/rust-lang/rust.extraheader
2019-08-13T08:00:52.4972812Z ##[command]git config --get-all http.proxy
2019-08-13T08:00:52.5111170Z ##[command]git -c http.extraheader="AUTHORIZATION: basic ***" fetch --force --tags --prune --progress --no-recurse-submodules --depth=2 origin +refs/heads/*:refs/remotes/origin/* +refs/pull/63512/merge:refs/remotes/pull/63512/merge
---
2019-08-13T08:01:30.2375865Z do so (now or later) by using -b with the checkout command again. Example:
2019-08-13T08:01:30.2375904Z 
2019-08-13T08:01:30.2376066Z   git checkout -b <new-branch-name>
2019-08-13T08:01:30.2376088Z 
2019-08-13T08:01:30.2376125Z HEAD is now at de4c4c165 Merge 44e58f748299111c0de9f7f1f6dda472bf0fe88f into 60960a260f7b5c695fd0717311d72ce62dd4eb43
2019-08-13T08:01:30.2520840Z ##[section]Starting: Collect CPU-usage statistics in the background
2019-08-13T08:01:30.2524000Z ==============================================================================
2019-08-13T08:01:30.2524058Z Task         : Bash
2019-08-13T08:01:30.2524105Z Description  : Run a Bash script on macOS, Linux, or Windows
---
2019-08-13T08:06:08.3385040Z    Compiling unwind v0.0.0 (/checkout/src/libunwind)
2019-08-13T08:06:08.8127640Z    Compiling build_helper v0.1.0 (/checkout/src/build_helper)
2019-08-13T08:06:10.3431331Z    Compiling compiler_builtins v0.1.18
2019-08-13T08:06:12.6545570Z    Compiling cmake v0.1.38
2019-08-13T08:06:14.5123877Z error: item has missing stability attribute
2019-08-13T08:06:14.5133207Z   --> src/libcore/task/poll.rs:86:5
2019-08-13T08:06:14.5140954Z    |
2019-08-13T08:06:14.5147001Z 86 | /     pub fn map_ok<U, F>(self, f: F) -> Poll<Option<Result<U, E>>>
2019-08-13T08:06:14.5173480Z 87 | |         where F: FnOnce(T) -> U
2019-08-13T08:06:14.5174189Z 89 | |         match self {
2019-08-13T08:06:14.5174418Z ...  |
2019-08-13T08:06:14.5175306Z 94 | |         }
2019-08-13T08:06:14.5175687Z 95 | |     }
2019-08-13T08:06:14.5175687Z 95 | |     }
2019-08-13T08:06:14.5175946Z    | |_____^
2019-08-13T08:06:14.5175983Z 
2019-08-13T08:06:14.5176232Z error: item has missing stability attribute
2019-08-13T08:06:14.5176536Z    --> src/libcore/task/poll.rs:98:5
2019-08-13T08:06:14.5176756Z     |
2019-08-13T08:06:14.5177113Z 98  | /     pub fn map_err<U, F>(self, f: F) -> Poll<Option<Result<T, U>>>
2019-08-13T08:06:14.5177476Z 99  | |         where F: FnOnce(E) -> U
2019-08-13T08:06:14.5178297Z 101 | |         match self {
2019-08-13T08:06:14.5178713Z ...   |
2019-08-13T08:06:14.5178938Z 106 | |         }
2019-08-13T08:06:14.5179170Z 107 | |     }
2019-08-13T08:06:14.5179170Z 107 | |     }
2019-08-13T08:06:14.5249680Z     | |_____^
2019-08-13T08:06:14.5249912Z 
2019-08-13T08:06:15.0062259Z error: aborting due to 2 previous errors
2019-08-13T08:06:15.0067143Z 
2019-08-13T08:06:15.1363055Z error: Could not compile `core`.
2019-08-13T08:06:15.1363336Z warning: build failed, waiting for other jobs to finish...
2019-08-13T08:06:15.4466575Z error: build failed
2019-08-13T08:06:15.4483822Z command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "check" "--target" "x86_64-unknown-linux-gnu" "-j" "2" "--release" "--color" "always" "--features" "panic-unwind backtrace compiler-builtins-c" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "--message-format" "json"
2019-08-13T08:06:15.4498526Z failed to run: /checkout/obj/build/bootstrap/debug/bootstrap check
2019-08-13T08:06:15.4498759Z Build completed unsuccessfully in 0:02:10
2019-08-13T08:06:15.4498759Z Build completed unsuccessfully in 0:02:10
2019-08-13T08:06:27.9929843Z ##[error]Bash exited with code '1'.
2019-08-13T08:06:27.9961442Z ##[section]Starting: Checkout
2019-08-13T08:06:27.9963767Z ==============================================================================
2019-08-13T08:06:27.9963823Z Task         : Get sources
2019-08-13T08:06:27.9963888Z Description  : Get sources from a repository. Supports Git, TfsVC, and SVN repositories.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@95th

This comment was marked as resolved.

Copy link
Contributor Author

commented Aug 13, 2019

Hi @nikomatsakis is this change acceptable? If yes, what change would I need to make to fix the error regarding the missing stability attr?

Show resolved Hide resolved src/libcore/task/poll.rs
Show resolved Hide resolved src/libcore/task/poll.rs
@Centril

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

@cramertj

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

These seem pretty undeniably useful, and API or implementation-wise I can't really imagine them working any other way. Let's get an opinion from someone on @rust-lang/libs first, though.

@cramertj

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

@bors r+

@Centril pointed out the precedent set here.

@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 13, 2019

📌 Commit 84cab92 has been approved by cramertj

@Centril

This comment has been minimized.

Copy link
Member

commented Aug 13, 2019

@bors rollup

(Btw, might be good to add some doctests +/- other tests in a follow up.)

Centril added a commit to Centril/rust that referenced this pull request Aug 14, 2019

Rollup merge of rust-lang#63512 - 95th:master, r=cramertj
Provide map_ok and map_err method for Poll<Option<Result<T, E>>>

Currently `map_ok` and `map_err` methods are given for `Poll<Result<T, E>>`.

This PR adds these methods for `Poll<Option<Result<T, E>>>` as they are helpful in stream building code.

bors added a commit that referenced this pull request Aug 14, 2019

Auto merge of #63541 - Centril:rollup-d3q7074, r=Centril
Rollup of 16 pull requests

Successful merges:

 - #62760 (Deduplicate error messages in `librsctc_mir`)
 - #62849 (typeck: Prohibit RPIT types that inherit lifetimes)
 - #63383 (`async fn` lifetime elision tests)
 - #63421 (Implement Clone, Display for ascii::EscapeDefault)
 - #63459 (syntax: account for CVarArgs being in the argument list.)
 - #63475 (Bring back suggestion for splitting `<-` into `< -`)
 - #63485 (ci: move mirrors to their standalone bucket)
 - #63486 (Document `From` trait for `BinaryHeap`)
 - #63488 (improve DiagnosticBuilder docs)
 - #63493 (Remove unneeded comment in src/libcore/hash/mod.rs)
 - #63499 (handle elision in async fn correctly)
 - #63501 (use `ParamName` to track in-scope lifetimes instead of Ident)
 - #63512 (Provide map_ok and map_err method for Poll<Option<Result<T, E>>>)
 - #63529 (RELEASES.md: ? is one of three Kleene operators)
 - #63530 (Fix typo in error message.)
 - #63534 (Bump to 1.39)

Failed merges:

r? @ghost

Centril added a commit to Centril/rust that referenced this pull request Aug 14, 2019

Rollup merge of rust-lang#63512 - 95th:master, r=cramertj
Provide map_ok and map_err method for Poll<Option<Result<T, E>>>

Currently `map_ok` and `map_err` methods are given for `Poll<Result<T, E>>`.

This PR adds these methods for `Poll<Option<Result<T, E>>>` as they are helpful in stream building code.

bors added a commit that referenced this pull request Aug 14, 2019

Auto merge of #63544 - Centril:rollup-qhqfcov, r=Centril
Rollup of 17 pull requests

Successful merges:

 - #62760 (Deduplicate error messages in `librsctc_mir`)
 - #62849 (typeck: Prohibit RPIT types that inherit lifetimes)
 - #63383 (`async fn` lifetime elision tests)
 - #63421 (Implement Clone, Display for ascii::EscapeDefault)
 - #63459 (syntax: account for CVarArgs being in the argument list.)
 - #63475 (Bring back suggestion for splitting `<-` into `< -`)
 - #63485 (ci: move mirrors to their standalone bucket)
 - #63486 (Document `From` trait for `BinaryHeap`)
 - #63488 (improve DiagnosticBuilder docs)
 - #63493 (Remove unneeded comment in src/libcore/hash/mod.rs)
 - #63499 (handle elision in async fn correctly)
 - #63501 (use `ParamName` to track in-scope lifetimes instead of Ident)
 - #63508 (Do not ICE when synthesizing spans falling inside unicode chars)
 - #63511 (ci: add a check for clock drift)
 - #63512 (Provide map_ok and map_err method for Poll<Option<Result<T, E>>>)
 - #63529 (RELEASES.md: ? is one of three Kleene operators)
 - #63530 (Fix typo in error message.)

Failed merges:

r? @ghost

bors added a commit that referenced this pull request Aug 14, 2019

Auto merge of #63544 - Centril:rollup-qhqfcov, r=Centril
Rollup of 17 pull requests

Successful merges:

 - #62760 (Deduplicate error messages in `librsctc_mir`)
 - #62849 (typeck: Prohibit RPIT types that inherit lifetimes)
 - #63383 (`async fn` lifetime elision tests)
 - #63421 (Implement Clone, Display for ascii::EscapeDefault)
 - #63459 (syntax: account for CVarArgs being in the argument list.)
 - #63475 (Bring back suggestion for splitting `<-` into `< -`)
 - #63485 (ci: move mirrors to their standalone bucket)
 - #63486 (Document `From` trait for `BinaryHeap`)
 - #63488 (improve DiagnosticBuilder docs)
 - #63493 (Remove unneeded comment in src/libcore/hash/mod.rs)
 - #63499 (handle elision in async fn correctly)
 - #63501 (use `ParamName` to track in-scope lifetimes instead of Ident)
 - #63508 (Do not ICE when synthesizing spans falling inside unicode chars)
 - #63511 (ci: add a check for clock drift)
 - #63512 (Provide map_ok and map_err method for Poll<Option<Result<T, E>>>)
 - #63529 (RELEASES.md: ? is one of three Kleene operators)
 - #63530 (Fix typo in error message.)

Failed merges:

r? @ghost
@bors

This comment has been minimized.

Copy link
Contributor

commented Aug 14, 2019

☔️ The latest upstream changes (presumably #63544) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors merged commit 84cab92 into rust-lang:master Aug 14, 2019

4 checks passed

pr Build #20190813.19 succeeded
Details
pr (Linux mingw-check) Linux mingw-check succeeded
Details
pr (Linux x86_64-gnu-llvm-6.0) Linux x86_64-gnu-llvm-6.0 succeeded
Details
pr (LinuxTools) LinuxTools succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.