-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix mut_mutex_lock
when reference not ultimately mutable
#13122
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
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @blyxyas (or someone else) some time within the next two weeks. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
I've just put the source code that the reporter talks about in a test case, and it seems to give the same error in this branch. Could you add a regression test and work off of it? 🌈 |
☔ The latest upstream changes (presumably #13440) made this pull request unmergeable. Please resolve the merge conflicts. |
When there is are multiple references where one of the references isn't mutable then this results in a false-positive for `mut_mutex_lock` as it only checks the mutability of the first reference level. Fix this by using `peel_mid_ty_refs_is_mutable` which correctly determines whether the reference is ultimately mutable and thus whether `Mutex::get_lock()` can actually be used. Fixes rust-lang#9854
Sorry for the delay, I've corrected the merge conflict and this should be ready to merge! If everything is green and [lintcheck] doesn't show anything weird, this will be merged today! ❤️ |
@bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
When there is are multiple references where one of the references isn't mutable then this results in a false-positive for
mut_mutex_lock
as it only checks the mutability of the first reference level.Fix this by using
peel_mid_ty_refs_is_mutable
which correctly determines whether the reference is ultimately mutable and thus whetherMutex::get_lock()
can actually be used.Fixes #9854
changelog: [
mut_mutex_lock
]: No longer lints if the mutex is behind multiple references and one of those references isn't mutable