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

It would be nice if JoinHandle<T> were must-use for T != () #52062

Open
scottmcm opened this Issue Jul 4, 2018 · 2 comments

Comments

Projects
None yet
4 participants
@scottmcm
Copy link
Member

scottmcm commented Jul 4, 2018

One IRC today, someone had code not working because they were doing

thread::spawn(|| mylib::my_function);

Which of course returns the function rather than running it.

Arguably it's almost always mistake to not keep the JoinHandle if the thread is going to return a non-unit value, since if you didn't care the closure could just be -> (), so this should lint, but AFAIK #[must_use] on the function or type would warn for JoinHandle<()> too today.

Repro link: https://play.rust-lang.org/?gist=fd8973579bf0bf474a7e2b9e135ff946&version=nightly

@varkor

This comment has been minimized.

Copy link
Member

varkor commented Nov 3, 2018

This looks like #48820, which was closed.

@jscinoz

This comment has been minimized.

Copy link

jscinoz commented Jan 14, 2019

I think this is subtly different - #48820 was for JoinHandle to be marked with #[must_use] in general, whereas this issue is for the more narrow scenario where the spawned thread returns value (implying that there's something still to be done with this value?.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.