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

lint idea: public Futures should be Send #5379

Closed
rkuhn opened this issue Mar 28, 2020 · 0 comments · Fixed by #5423
Closed

lint idea: public Futures should be Send #5379

rkuhn opened this issue Mar 28, 2020 · 0 comments · Fixed by #5423
Labels
A-lint Area: New lints L-style Lint: Belongs in the style lint group T-async-await Type: Issues related to async/await

Comments

@rkuhn
Copy link
Contributor

rkuhn commented Mar 28, 2020

One possible result of this discussion on Rust internals could be a lint that helps library maintainers in the large and the small (i.e. also between modules of the same crate) produce useful Future implementations when multithreaded executors are a possible runtime target. The lint would be disabled when targeting embedded systems where Futures are multiplexed onto the current thread only.

Informally specified, the rule would be that for any public function or method that returns an implementation of Future the return type must also be Send.

Is this feasible? Is this desirable?

@flip1995 flip1995 added L-style Lint: Belongs in the style lint group A-lint Area: New lints T-async-await Type: Issues related to async/await labels Mar 30, 2020
bors added a commit that referenced this issue Apr 17, 2020
add lint futures_not_send

changelog: add lint futures_not_send

fixes #5379

~Remark: one thing that can (should?) still be improved is to directly include the error message from the `Send` check so that the programmer stays in the flow. Currently, getting the actual error message requires a restructuring of the code to make the `Send` constraint explicit.~
It now shows all unmet constraints for allowing the Future to be Send.
@bors bors closed this as completed in f1fb815 Apr 17, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lint Area: New lints L-style Lint: Belongs in the style lint group T-async-await Type: Issues related to async/await
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants