When encountering move error on an Option, suggest using as_ref#61147
When encountering move error on an Option, suggest using as_ref#61147bors merged 2 commits intorust-lang:masterfrom
Option, suggest using as_ref#61147Conversation
|
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
|
r? @oli-obk |
|
Does this correctly handle |
|
Perhaps this should support |
|
@czipperz adding
Could you expand? |
|
I don't know if this is possible, but it would be nice if it suggested |
There was a problem hiding this comment.
How do you feel about waiting a bit with merging this PR (a bit being until #60966 is merged)? Then you can annotate Option and Result with #[rustc_diagnostic_item = "option"] and "result" respectively and then check for these items via
if let Some(adt) = original_path.ty(self.mir, self.infcx.tcx).adt_def() {
if self.infcx.tcx.is_diagnostic_item(adt.did, sym::option) {
...
}
}There was a problem hiding this comment.
There are a couple of places where we're already doing string comparisons like this, so I love the fact that we'll be able to get rid of them soon!
There was a problem hiding this comment.
Hmm... or we can just merge this and fix it up later, doesn't seem like a big deal in fact.
There was a problem hiding this comment.
I'm fine either way
|
@czipperz suggesting both is bit heavy, but can be done. I'm a bit ambivalent on whether it is worth it. On one hand, it teaches the API surface nicely, on the other hand it is verbose and might confuse newcomers. |
|
My vote is for just suggesting |
|
Should I just remove the last commit or are there any further changes needed (beyond #60966)? |
|
r=me with last commit removed. I agree with your assessment that we'd be overwhelming users for little gain |
|
@bors r=oli-obk |
|
📌 Commit 1cc42ea has been approved by |
|
☀️ Test successful - checks-travis, status-appveyor |
Fix #61109, cc #15457.