-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Suggest using as_ref
on some borrow errors [hack]
#51100
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
(rust_highfive has picked a reviewer for you, use r? to override) |
cc @oli-obk @kornelski @scottmcm from the original issue. This is not a nice solution, but given that this is a common pitfall for newcomers, I wanted to have some support for a suggestion. |
This comment has been minimized.
This comment has been minimized.
Yea, having a hacky solution for Result and Option is better than the original confusing error message. |
r? @oli-obk (you seem to know more about this) |
@bors r+ |
📌 Commit 46d0f22 has been approved by |
🔒 Merge conflict |
When encountering the following code: ```rust struct Foo; fn takes_ref(_: &Foo) {} let ref opt = Some(Foo); opt.map(|arg| takes_ref(arg)); ``` Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead. This is a stop gap solution until we expand typeck to deal with these cases in a more graceful way.
@bors r=oli-obk rebased against master |
📌 Commit a19a03a has been approved by |
Suggest using `as_ref` on some borrow errors [hack] When encountering the following code: ```rust struct Foo; fn takes_ref(_: &Foo) {} let ref opt = Some(Foo); opt.map(|arg| takes_ref(arg)); ``` Suggest using `opt.as_ref().map(|arg| takes_ref(arg));` instead. This is a stop gap solution until we expand typeck to deal with these cases in a more graceful way. #43861
☀️ Test successful - status-appveyor, status-travis |
When encountering the following code:
Suggest using
opt.as_ref().map(|arg| takes_ref(arg));
instead.This is a stop gap solution until we expand typeck to deal with these
cases in a more graceful way.
#43861