-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[new-lint] if let Some... else with locked mutex #5219
Comments
I should be using the latest nightly for testing a PR right? Is there a branch that is rustc 1.43.0-nightly current to start working from or is this a case where I should start with an update PR? @matthiaskrgr where did you start your PR from your |
Clippy is compiled with the latest master commit of rustc, not with the latest nightly. (I think the 2020-02-25 nightly should work right now, though) The |
If let else mutex changelog: Adds lint to catch incorrect use of `Mutex::lock` in `if let` expressions with lock calls in any of the blocks. closes: #5219
failed on let vec_mutex = Mutex::new(vec![2,3]);
if let Some(num) = vec_mutex.lock().unwrap().pop() {
if num == 2 {
vec_mutex.lock().unwrap().push(4);
}
println!("got {num}");
}; |
I was working on a project and did something like this
It just sat running and it took me a bit to realize the mutex is locked for the entire scope of the
if
andelse
. The suggestion could be something likeor a suggestion to
I would be happy to start a PR if this sounds good to anyone else!
The text was updated successfully, but these errors were encountered: