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

Add ?Sized bound for MutexGuard::map and OwnedMutexGuard::map. #5997

Merged
merged 1 commit into from
Sep 10, 2023

Conversation

ennis
Copy link
Contributor

@ennis ennis commented Sep 10, 2023

Motivation

I can't return a reference to an unsized type in MutexGuard::map and OwnedMutexGuard::map because of an implicit Sized bound in their signature.

Solution

Add a ?Sized bound to the signatures of the two methods. It seems safe at a glance (the mapped guard types already have ?Sized), but there might be some subtlety somewhere that I overlooked.

The guard structs already have `?Sized` but the function to produce them had an implicit `Sized` bound on the type parameter.
@github-actions github-actions bot added the R-loom-sync Run loom sync tests on this PR label Sep 10, 2023
@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync labels Sep 10, 2023
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@Darksonn Darksonn merged commit 61f095f into tokio-rs:master Sep 10, 2023
75 checks passed
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 M-sync Module: tokio/sync R-loom-sync Run loom sync tests on this PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants