Suggest dereferencing when Deref is implemented.#60155
Suggest dereferencing when Deref is implemented.#60155bors merged 3 commits intorust-lang:masterfrom
Deref is implemented.#60155Conversation
This commit adds a test that demonstrates the current behaviour where suggestions to add a dereference aren't given for non-references.
This commit suggests dereferencing a type when it implements `Deref` with the correct `Output` associated type.
src/librustc_typeck/check/demand.rs
Outdated
There was a problem hiding this comment.
Seems like a good place to refactor into function(s)?
|
General note: When I wrote the issue I hoped that we could deduplicate the logic on references with the new logic you wrote. References also implement |
I just tried this and I don't think it does, when I check if |
Maybe we need to try something different then. Check whether the type implements |
I have no idea what I was trying earlier, pushed a version that de-duplicates that logic. |
This commit makes the suggestion to dereference when a type implements `Deref` only apply if the dereference would succeed (ie. the type is `Copy`, otherwise a borrow check error would occur).
|
@bors r+ This is absolutely awesome! |
|
📌 Commit 7ab1bfd has been approved by |
|
☀️ Test successful - checks-travis, status-appveyor |
Fixes #59819.
r? @oli-obk
cc @estebank