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
Make Option<T> #[must_use]
if T is
#71368
Comments
Why do you create an option and do nothing with it? |
did I minimize this example too far?... actual code was closer to:
|
The issue is that |
Also see #67387 ( |
Nominating for @rust-lang/lang consideration. This is another case where extending I was pondering why it makes sense, and I think the reason is pretty clear -- an |
From wg-async-foundations triage: marking On Deck, because forgetting to await is a fairly common thing, and part of the learnability story for async/await is making sure you don't do that. |
How feasible would it be to detect taking a |
What about making the enum variant constructors themselves |
Marking the variant constructor Also, I think we might well want to warn on code like the following: fn foo() -> Option<impl Future> { ... }
fn bar() {
foo();
} I'm not quite I understand what @joshtriplett is proposing. It sounds like saying "if you construct a enum or struct variant that contains a I'd like to ask: what is the resistance to making |
I support making In https://fuchsia-review.googlesource.com/c/fuchsia/+/501960/9/src/sys/component_manager/src/capability.rs#173, I wanted to have a trait method returning a
I wanted |
#[must_use]
if T is
I was recently refactoring some code that originally looked like this (minimized):
bar() was far away from the definition of foo().
I had need to refactor the code so that foo was also async, and so now I had:
This gives no compiler diagnostic and instead the body of foo is not executed.
The text was updated successfully, but these errors were encountered: