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

EnterGuard<> must always be used #3608

Closed
farazshaikh opened this issue Mar 12, 2021 · 1 comment
Closed

EnterGuard<> must always be used #3608

farazshaikh opened this issue Mar 12, 2021 · 1 comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug.

Comments

@farazshaikh
Copy link
Contributor

**Version
tokio v1.3.0 (*)

Platform
all

Description
{
handle.enter(); // IMO Never makes sense to immediately drop the handle.
foo..
}

[short summary of the bug]
For "some" reason we ended up creating 2 runtimes in a project.
We used .enter() to specifically tie some code down to one of specific runtimes.
Missing the ```let _guard = `` part didn't get flagged by the compiler.
Overall caused some confusion as the code rightly didn't work as executed.

runtime {
   let nested_runtime = runtime::new
   nested_runtime::enter();   // missed the let binding. Intention was to use the nested runtime.
}

I expected to see this happen:
The compiler should have warned, linter should have warned. Code should not have compiled.

Instead, this happened:
Code compiled and didn't worked as intended.

@farazshaikh farazshaikh added A-tokio Area: The main tokio crate C-bug Category: This is a bug. labels Mar 12, 2021
@farazshaikh farazshaikh changed the title annotate attribute must_use for Runtime::Handle::enter() and friends EnterGuard<> must always be used Mar 12, 2021
@Darksonn
Copy link
Contributor

Closed by #3609

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate C-bug Category: This is a bug.
Projects
None yet
Development

No branches or pull requests

2 participants