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

Mention Result<!, E> in never docs. #49988

Merged
merged 2 commits into from
May 9, 2018
Merged

Conversation

clarfonthey
Copy link
Contributor

Fixes #48096.

@rust-highfive
Copy link
Collaborator

r? @sfackler

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 15, 2018
@sfackler
Copy link
Member

r? @steveklabnik

@rust-highfive
Copy link
Collaborator

Your PR failed on Travis (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.
[00:00:46] configure: rust.quiet-tests     := True
---
[00:05:40] tidy error: /checkout/src/libstd/primitive_docs.rs:178: trailing whitespace
[00:05:41] some tidy checks failed
[00:05:41]
[00:05:41]
[00:05:41] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:41] expected success, got: exit code: 1
[00:05:41]
[00:05:41]
[00:05:41] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:41] Build completed unsuccessfully in 0:02:32
[00:05:41] make: *** [tidy] Error 1
[00:05:41] Makefile:79: recipe for target 'tidy' failed
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:15693899:start=1523827160198752133,finish=1523827160206541759,duration=7789626
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:0240e069
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:0240e069:start=1523827160213176373,finish=1523827160220525100,duration=7348727
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:35dadb14
$ dmesg | grep -i kill
[   10.523986] init: failsafe main process (1095) killed by TERM signal

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
Copy link
Collaborator

Your PR failed on Travis (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.
[00:00:47] configure: rust.quiet-tests     := True
---
[00:05:14] tidy error: /checkout/src/libstd/primitive_docs.rs:178: trailing whitespace
[00:05:15] some tidy checks failed
[00:05:15]
[00:05:15]
[00:05:15] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:05:15] expected success, got: exit code: 1
[00:05:15]
[00:05:15]
[00:05:15] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:05:15] Build completed unsuccessfully in 0:02:02
[00:05:15] make: *** [tidy] Error 1
[00:05:15] Makefile:79: recipe for target 'tidy' failed
---
$ ls -lat $HOME/Library/Logs/DiagnosticReports/
ls: cannot access /home/travis/Library/Logs/DiagnosticReports/: No such file or directory
travis_time:end:2bb44d5a:start=1523828998949416604,finish=1523828998956771530,duration=7354926
travis_fold:end:after_failure.2
travis_fold:start:after_failure.3
travis_time:start:056baa30
$ find $HOME/Library/Logs/DiagnosticReports -type f -name '*.crash' -not -name '*.stage2-*.crash' -not -name 'com.apple.CoreSimulator.CoreSimulatorService-*.crash' -exec printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" {} \; -exec head -750 {} \; -exec echo travis_fold":"end:crashlog \; || true
find: `/home/travis/Library/Logs/DiagnosticReports': No such file or directory
travis_time:end:056baa30:start=1523828998962745853,finish=1523828998969647555,duration=6901702
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:060dfafd
$ dmesg | grep -i kill
[   10.817069] init: failsafe main process (1092) killed by TERM signal

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
Copy link
Collaborator

Your PR failed on Travis (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.
[00:00:46] configure: rust.quiet-tests     := True
---
[00:48:39] .................................................................................i..................
[00:48:45] ........................i...........................................................................
---
[00:49:29] .......................i...........................................................................i
[00:49:35] ....................................................................................................
[00:49:42] .............ii.....................................................................................
---
[00:50:30] .............................................i......................................................
---
[00:54:37] ..............................i.....................................................................
[00:54:52] ...............................................................i....................................
[00:55:07] .................................................i..................................................
[00:55:28] ....................................................................................................
[00:55:51] ....................................................................................................
[00:56:13] ....................................................................................................
[00:56:39] .......i............................................................................................
[00:57:06] ...i............................................................................test [run-pass] run-pass/mir_heavy_promoted.rs has been running for over 60 seconds
[00:57:16] ....................
[00:57:49] ....................................................................................................
[00:58:22] .....................................................................ii.............................
[00:59:13] ................................i...........................................test [run-pass] run-pass/saturating-float-casts.rs has been running for over 60 seconds
[00:59:21] .........i.ii...........
[01:00:06] .............................................................................................iiiiiii
---
[01:02:23] ...................i............................................................ii.iii..............
[01:02:30] ....................................................................................................
[01:02:39] ........i..............................i............................................................
[01:02:46] ....................................................................................................
[01:02:53] ..........i.........................................................................................
[01:03:02] ....................................................................................................
[01:03:12] ....................................................................................................
[01:03:22] ....................................................................................................
[01:03:33] ....................................................................................................
[01:03:47] ....................................................................................................
[01:03:55] ...i................................................................................................
[01:04:04] .......i..ii........................................................................................
[01:04:15] ....................................................................................................
[01:04:24] ....................................................................................................
[01:04:34] .........................................................................i..........................
[01:04:45] ...................i................................................................................
---
[01:05:19] ...........................i........................................................................
[01:05:21] ....................................................................i...............................
[01:05:22] ................i.......................................................
---
[01:05:37] .............i........................
---
[01:06:08] i...i..ii....i.............ii.........iii......i..i...i...ii..i..i..ii.....
---
[01:06:12] i.......i......................i.......
---
[01:06:53] iiii.......i..i........i..i.i.............i..........iiii...........i...i..........ii.i.i.......ii..
[01:06:54] ....ii...
---
[01:15:29] ..................i.................................................................................
[01:17:08] .......i............................................................................................
---
[01:19:18] .....................................i..............................................................
[01:19:40] ....................................................................................................
[01:20:03] ..........................................i.........................................................
---
[01:21:42] .........................................................ii.........................................
---
[01:23:11] .....................i..............................................................................
---
[01:29:05] ii..................................................................................................
[01:29:26] ....................................................................................................
[01:29:44] .......................iii......i......i...i......i.................................................
[01:29:54] ....................................................................................................
[01:30:10] .............................................iiii........ii.........................................
[01:30:23] ....................................................................................................
[01:30:41] ............................................................................................i.F.F.F.
[01:31:07] ....................................................................................................
[01:31:21] ....................................................................................................
[01:31:32] .....iiii...............................................
[01:31:32] failures:
[01:31:32]
[01:31:32] ---- primitive_docs.rs - prim_never (line 154) stdout ----
[01:31:32]  error[E0425]: cannot find function `get_request` in this scope
[01:31:32]  --> primitive_docs.rs:156:29
[01:31:32]   |
[01:31:32] 5 |     let (client, request) = get_request().expect("disconnected");
[01:31:32]   |                             ^^^^^^^^^^^ not found in this scope
[01:31:32]
[01:31:32] thread 'primitive_docs.rs - prim_never (line 154)' panicked at 'couldn't compile the test', librustdoc/test.rs:318:13
[01:31:32] note: Run with `RUST_BACKTRACE=1` for a backtrace.
[01:31:32]
[01:31:32] ---- primitive_docs.rs - prim_never (line 167) stdout ----
[01:31:32]  error[E0425]: cannot find function `get_request` in this scope
[01:31:32]  --> primitive_docs.rs:169:11
[01:31:32]   |
[01:31:32] 5 |     match get_request() {
[01:31:32]   |           ^^^^^^^^^^^ not found in this scope
[01:31:32]
[01:31:32] thread 'primitive_docs.rs - prim_never (line 167)' panicked at 'couldn't compile the test', librustdoc/test.rs:318:13
[01:31:32]
[01:31:32] ---- primitive_docs.rs - prim_never (line 182) stdout ----
[01:31:32]  error[E0412]: cannot find type `ConnectionError` in this scope
[01:31:32]  --> primitive_docs.rs:183:31
[01:31:32]   |
[01:31:32] 4 | fn server_loop() -> Result<!, ConnectionError> {
[01:31:32]   |                               ^^^^^^^^^^^^^^^ not found in this scope
[01:31:32]
[01:31:32] error[E0425]: cannot find function `get_request` in this scope
[01:31:32]  --> primitive_docs.rs:185:33
[01:31:32]   |
[01:31:32] 6 |         let (client, request) = get_request()?;
[01:31:32]   |                                 ^^^^^^^^^^^ not found in this scope
[01:31:32]
[01:31:32] error: unreachable expression
[01:31:32]  --> primitive_docs.rs:184:5
[01:31:32]   |
[01:31:32] 5 | /     Ok(loop {
[01:31:32] 6 | |         let (client, request) = get_request()?;
[01:31:32] 7 | |         let response = request.process();
[01:31:32] 8 | |         response.send(client);
[01:31:32] 9 | |     })
[01:31:32]   | |______^
---
[01:31:32]   = note: #[deny(unreachable_code)] implied by #[deny(warnings)]
[01:31:32]
[01:31:32] thread 'primitive_docs.rs - prim_never (line 182)' panicked at 'couldn't compile the test', librustdoc/test.rs:318:13
---
[01:31:32] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "x86_64-unknown-linux-gnu" "--release" "--locked" "--color" "always" "--features" "panic-unwind jemalloc backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "std" "--" "--quiet"
[01:31:32] expected success, got: exit code: 101
[01:31:32]
[01:31:32]
[01:31:32] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[01:31:32] Build completed unsuccessfully in 0:44:15
[01:31:32] Makefile:58: recipe for target 'check' failed
[01:31:32] make: *** [check] Error 1
---
121760 ./obj/build/bootstrap/debug/incremental/bootstrap-351vorei3hhuv/s-f05gazxpuo-1560aao-3ssff2uugm5rt
---
102512 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release/incremental/core-31lccp6wy7orz/s-f05hha4jpu-3sh9uk-bcs1sclq83s
100744 ./obj/build/bootstrap/debug/incremental/bootstrap-zki88qpb4pjm
100740 ./obj/build/bootstrap/debug/incremental/bootstrap-zki88qpb4pjm/s-f05hk45zgm-1798b1g-2fm8hlvdg42qh
---
55760 ./obj/build/x86_64-unknown-linux-gnu/stage1-rustc/x86_64-unknown-linux-gnu/release/incremental/syntax-33oa6nnkk1g08/s-f05hj8jf9t-xeq3dt-1h8qobzzqy5ls

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)

@@ -112,6 +112,8 @@ mod prim_bool { }
///
/// # `!` and generics
///
/// ## Infalliable errors

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: Infalliable -> Infallible

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still needs fixed

@@ -140,9 +142,59 @@ mod prim_bool { }
/// [`Ok`] variant. This illustrates another behaviour of `!` - it can be used to "delete" certain
/// enum variants from generic types like `Result`.
///
/// ## Infinite loops
///
/// While [`Result<T, !>`] is very useful for removing errors, `!` can also be used to removed

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: removed -> remove

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

/// instead:
///
/// ```ignore (hypothetical-example)
/// fn server_loop() -> Result<!, ConnectionError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like this example 👍 A thought: with #49162, it could even be

fn main() -> Result<!, ConnectionError>

Also, I think the Ok( isn't needed because loop returns !, which will coerce to the Result: https://play.rust-lang.org/?gist=1cc0b7e8032bec565768ab95f42c454d&version=nightly

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My main reasoning for not making this main is that the idea is that you might in principle want a larger loop that handles the error. Also, while I agree that the loop can be coerced to Ok, I think that wrapping in an Ok is best to draw parallels to a non-infinite loop. If it seems more clear the other way though, I'll definitely change it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to leave off the Ok, but I can agree that this being not main makes a lot of sense

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave off the Ok and explain the coercion.

@pietroalbini
Copy link
Member

Ping from triage @steveklabnik! This PR needs your review!

Copy link
Member

@steveklabnik steveklabnik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some typos, but other than that, looks good! Thank you!

@@ -112,6 +112,8 @@ mod prim_bool { }
///
/// # `!` and generics
///
/// ## Infalliable errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this still needs fixed

@@ -140,9 +142,59 @@ mod prim_bool { }
/// [`Ok`] variant. This illustrates another behaviour of `!` - it can be used to "delete" certain
/// enum variants from generic types like `Result`.
///
/// ## Infinite loops
///
/// While [`Result<T, !>`] is very useful for removing errors, `!` can also be used to removed
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

///
/// For example, consider the case of a simple web server, which can be simplified to:
///
/// ```ignore (hypothetical-example)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen this notation, does this work?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually copied it from an example earlier in the file, so, I assume so?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It doesn't do anything. It's recognized as non-rust code. That's pretty much all.

/// instead:
///
/// ```ignore (hypothetical-example)
/// fn server_loop() -> Result<!, ConnectionError> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to leave off the Ok, but I can agree that this being not main makes a lot of sense

@clarfonthey
Copy link
Contributor Author

I'll try and make the desired changes later today.

@aturon
Copy link
Member

aturon commented Apr 25, 2018

@bors: rollup

@clarfonthey
Copy link
Contributor Author

Err, I haven't made the changes yet.

@clarfonthey
Copy link
Contributor Author

Actually made the changes; sorry it took so long.

@rust-highfive
Copy link
Collaborator

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (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.

[00:04:56] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:04:56] tidy error: /checkout/src/libstd/primitive_docs.rs:182: trailing whitespace
[00:04:57] some tidy checks failed
[00:04:57] 
[00:04:57] 
[00:04:57] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:04:57] 
[00:04:57] 
[00:04:57] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:04:57] Build completed unsuccessfully in 0:02:01
[00:04:57] Build completed unsuccessfully in 0:02:01
[00:04:57] make: *** [tidy] Error 1
[00:04:57] Makefile:79: recipe for target 'tidy' failed

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:091df37c
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

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)

@TimNN
Copy link
Contributor

TimNN commented May 8, 2018

Ping from triage @steveklabnik ! This PR is awaiting your review.

@steveklabnik
Copy link
Member

@bors: r+ rollup

thanks!

@bors
Copy link
Contributor

bors commented May 8, 2018

📌 Commit fc6d6c9 has been approved by steveklabnik

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 8, 2018
kennytm added a commit to kennytm/rust that referenced this pull request May 9, 2018
bors added a commit that referenced this pull request May 9, 2018
Rollup of 11 pull requests

Successful merges:

 - #49988 (Mention Result<!, E> in never docs.)
 - #50148 (turn `ManuallyDrop::new` into a constant function)
 - #50456 (Update the Cargo submodule)
 - #50460 (Make `String::new()` const)
 - #50464 (Remove some transmutes)
 - #50505 (Added regression function match value test)
 - #50511 (Add some explanations for #[must_use])
 - #50525 (Optimize string handling in lit_token().)
 - #50527 (Cleanup a `use` in a raw_vec test)
 - #50539 (Add more logarithm constants)
 - #49523 (Update RELEASES.md for 1.26.0)

Failed merges:
@bors bors merged commit fc6d6c9 into rust-lang:master May 9, 2018
@clarfonthey clarfonthey deleted the never_docs branch June 22, 2018 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.