Skip to content

doc test: fix mpsc.rs try_send doc test #145299

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eval-exec
Copy link
Contributor

@eval-exec eval-exec commented Aug 12, 2025

This Pr want to fix the doctest, to make #145293 's CI pass:

r? @Zalathar

https://github.com/rust-lang/rust/actions/runs/16903356990/job/47887354221

2025-08-12T10:19:32.3873237Z test library/std/src/thread/scoped.rs - thread::scoped::ScopedJoinHandle<'scope,T>::join (line 302) ... ok
2025-08-12T10:19:32.4370250Z test library/std/src/time.rs - time::SystemTimeError::duration (line 688) ... ok
2025-08-12T10:19:32.5121966Z test library/std/src/time.rs - time::UNIX_EPOCH (line 664) ... ok
2025-08-12T10:19:32.5122586Z 
2025-08-12T10:19:32.5122738Z failures:
2025-08-12T10:19:32.5122973Z 
2025-08-12T10:19:32.5123482Z ---- library/std/src/sync/mpsc.rs - sync::mpsc::SyncSender<T>::try_send (line 691) stdout ----
2025-08-12T10:19:32.5124286Z Test executable failed (exit status: 1).
2025-08-12T10:19:32.5124518Z 
2025-08-12T10:19:32.5124605Z stdout:
2025-08-12T10:19:32.5124810Z message 3 received
2025-08-12T10:19:32.5125043Z message 1 received
2025-08-12T10:19:32.5125288Z the third message was never sent
2025-08-12T10:19:32.5125497Z 
2025-08-12T10:19:32.5125581Z stderr:
2025-08-12T10:19:32.5125701Z 
2025-08-12T10:19:32.5125935Z thread '<unnamed>' (203874) panicked at library/std/src/sync/mpsc.rs:14:25:
2025-08-12T10:19:32.5126459Z called `Result::unwrap()` on an `Err` value: SendError { .. }
2025-08-12T10:19:32.5126836Z stack backtrace:
2025-08-12T10:19:32.5127568Z ␛[0m␛[1m␛[38;5;9merror␛[0m␛[0m␛[1m: the main thread terminated without waiting for all remaining threads␛[0m
2025-08-12T10:19:32.5127971Z 
2025-08-12T10:19:32.5128335Z ␛[0m␛[1m␛[38;5;10mnote␛[0m␛[0m␛[1m: set `MIRIFLAGS=-Zmiri-ignore-leaks` to disable this check␛[0m
2025-08-12T10:19:32.5128694Z 
2025-08-12T10:19:32.5128943Z ␛[0m␛[1m␛[38;5;9merror␛[0m␛[0m␛[1m: aborting due to 1 previous error␛[0m
2025-08-12T10:19:32.5129519Z 
2025-08-12T10:19:32.5129527Z 
2025-08-12T10:19:32.5129532Z 
2025-08-12T10:19:32.5129537Z 
2025-08-12T10:19:32.5129631Z failures:
2025-08-12T10:19:32.5130018Z     library/std/src/sync/mpsc.rs - sync::mpsc::SyncSender<T>::try_send (line 691)
2025-08-12T10:19:32.5130396Z 
2025-08-12T10:19:32.5130713Z test result: FAILED. 999 passed; 1 failed; 16 ignored; 0 measured; 344 filtered out; finished in 105.92s

@rustbot
Copy link
Collaborator

rustbot commented Aug 12, 2025

r? @ibraheemdev

rustbot has assigned @ibraheemdev.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 12, 2025
@rustbot rustbot assigned Zalathar and unassigned ibraheemdev Aug 12, 2025
@Zalathar
Copy link
Contributor

I can't approve this because I'm not on the appropriate team, but it does seem simpler and more reliable than the existing test.

r? libs

Copy link
Contributor

@tgross35 tgross35 left a comment

Choose a reason for hiding this comment

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

I don't think the correct fix here is to change to single-threaded: mpsc is, after all, meant to be used in multithreaded environments.

The correct thing to do here is save the handles from spawn and .join them at the end of the test https://doc.rust-lang.org/std/thread/fn.spawn.html#examples

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 12, 2025
@eval-exec
Copy link
Contributor Author

I don't think the correct fix here is to change to single-threaded: mpsc is, after all, meant to be used in multithreaded environments.

The correct thing to do here is save the handles from spawn and .join them at the end of the test https://doc.rust-lang.org/std/thread/fn.spawn.html#examples

Thank you, I will push another commit to moidfy the doctest.

Signed-off-by: Eval EXEC <execvy@gmail.com>
@eval-exec eval-exec requested a review from tgross35 August 13, 2025 13:10
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants