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

Don't encourage people to ignore threading errors in the docs #44962

Merged
merged 1 commit into from
Oct 10, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions src/libstd/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -485,15 +485,17 @@ impl Builder {
/// let (tx, rx) = channel();
///
/// let sender = thread::spawn(move || {
/// let _ = tx.send("Hello, thread".to_owned());
/// tx.send("Hello, thread".to_owned())
/// .expect("Unable to send on channel");
Copy link
Member

Choose a reason for hiding this comment

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

Invalid indent, should be:

tx.send("Hello, thread".to_owned())
  .expect("Unable to send on channel");

Copy link
Member Author

Choose a reason for hiding this comment

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

Invalid indent

Huh. Rustfmt is what indented it this way. Where is this style documented so I can check it before submitting future PRs?

Copy link
Member

Choose a reason for hiding this comment

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

rustfmt is really bad... Well, whatever, please align the methods' calls.

Copy link
Member Author

Choose a reason for hiding this comment

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

Where is this style documented so I can check it before submitting future PRs?

Copy link
Member

Choose a reason for hiding this comment

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

No clue. It's how it's done in the rest of rustc source code. Sorry but I have no idea if there is such a document...

/// });
///
/// let receiver = thread::spawn(move || {
/// println!("{}", rx.recv().unwrap());
/// let value = rx.recv().expect("Unable to receive from channel");
/// println!("{}", value);
/// });
///
/// let _ = sender.join();
/// let _ = receiver.join();
/// sender.join().expect("The sender thread has panicked");
/// receiver.join().expect("The receiver thread has panicked");
/// ```
///
/// A thread can also return a value through its [`JoinHandle`], you can use
Expand Down Expand Up @@ -1192,7 +1194,7 @@ impl<T> JoinInner<T> {
/// });
/// });
///
/// let _ = original_thread.join();
/// original_thread.join().expect("The thread being joined has panicked");
/// println!("Original thread is joined.");
///
/// // We make sure that the new thread has time to run, before the main
Expand Down