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

Fix mut_mutex_lock when Mutex is behind immutable deref #9418

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

lukaslueg
Copy link
Contributor

I think the problem here is the if let ty::Ref(_, _, Mutability::Mut) = cx.typeck_results().expr_ty(recv).kind() line tries to check if the Mutex can be mutably borrowed (there already is a test for Arc<Mutex<_>>), but gets bamboozled by the &mut Arc indirection. And I think checking the deref-adjustment to filter immutable-adjust (the deref through the Arc, starting from &mut Arc) is the correct fix.

Fixes #9415

changelog: Fix mut_mutex_lock when Mutex is behind immutable deref

@rust-highfive
Copy link

r? @llogiq

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Sep 2, 2022
@llogiq
Copy link
Contributor

llogiq commented Sep 2, 2022

Thank you!

@bors r+

@bors
Copy link
Collaborator

bors commented Sep 2, 2022

📌 Commit ffc75af has been approved by llogiq

It is now in the queue for this repository.

@bors
Copy link
Collaborator

bors commented Sep 2, 2022

⌛ Testing commit ffc75af with merge c36696a...

@bors
Copy link
Collaborator

bors commented Sep 2, 2022

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: llogiq
Pushing c36696a to master...

@bors bors merged commit c36696a into rust-lang:master Sep 2, 2022
@lukaslueg lukaslueg deleted the issue9415 branch September 2, 2022 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

False positive mut_mutex_lock on &mut Arc<Mutex<_>>
4 participants