Uh oh!
There was an error while loading. Please reload this page.
Be more obvious when suggesting dereference - #45947
Conversation
mark-i-m
commented
Nov 12, 2017
I'm still not quite sure I understand the error... Isn't |
estebank
commented
Nov 13, 2017
mark-i-m
commented
Nov 13, 2017
It is a pattern match, though, right? I was under the impression that in Rust all arguments to functions and closures are actually patterns, which can bind new names, just as in an Another way of asking the question is to ask if |
mark-i-m
commented
Nov 13, 2017
Ah, I see. The correct pattern would be |
mark-i-m
commented
Nov 13, 2017
Hmm... so the hint was actually on the right track. It suggests replacing |
arielb1
commented
Nov 13, 2017
Can't we just adjust our error message until it includes all the surrounding reference patterns, so we'll get this: error: non-reference pattern used to match a reference(see issue #42640)
--> src/coord.rs:194:23
|
194 | .filter(|&(ref k, _)| self.hash(k) == server)
| ^^^^^^^^^^^ help: consider using: `&&(ref k, _)`
|
= help: add #![feature(match_default_bindings)] to the crate attributes to enable
error: aborting due to previous error
error:Could not compile `kv_2pc`.To learn more, run the command again with --verbose. |
estebank
commented
Nov 13, 2017
@arielb1 yeah, I think that's a better approach. |
kennytm
commented
Nov 22, 2017
Hi @estebank, what is the status of this PR? |
8b8dbaa to
8ca6925Compareestebank
commented
Nov 23, 2017
mark-i-m
commented
Nov 23, 2017
What problems do you foresee with it? |
There was a problem hiding this comment.
Doesn't this mean we now have the same problem with the following case:
let x = &&&0;let&&x = x;IIUC, the error message would suggest using &&, right?
There was a problem hiding this comment.
This looks likely to introduce an infinite loop in some case, where we go up to the start of the file. You can return an Option<Span> instead.
Please don't fiddle with spans, it causes very weird situations with macros. You can use |
b28b38e to
f1a672cCompareThere was a problem hiding this comment.
ok a while-let would be ugly too. Why can't we have a do-while loop?
arielb1
commented
Nov 23, 2017
@bors r+ |
bors
commented
Nov 23, 2017
📌 Commit f1a672c has been approved by |
kennytm
commented
Nov 24, 2017
@bors r- CI failed, the UI test |
bors
commented
Nov 24, 2017
☔ The latest upstream changes (presumably #46116) made this pull request unmergeable. Please resolve the merge conflicts. |
Include enclosing span when suggesting dereference on a span that is already a reference: ``` error: non-reference pattern used to match a reference (see issue rust-lang#42640) --> dont-suggest-dereference-on-arg.rs:16:19 | 16 | .filter(|&(ref a, _)| foo(a)) | ^^^^^^^^^^^ help: consider using: `&&(ref k, _)` | = help: add #![feature(match_default_bindings)] to the crate attributes to enable ```
33f0684 to
48d291aCompareThere was a problem hiding this comment.
[00:47:09] error: /checkout/src/test/ui/suggestions/dont-suggest-dereference-on-arg.rs:16: unexpected help message: '16:18: 16:29: add #![feature(match_default_bindings)] to the crate attributes to enable'
Needs one more //~| HELP.
48d291a to
15dfd7eCompareestebank
commented
Nov 25, 2017
@bors r=arielb1 |
bors
commented
Nov 25, 2017
📌 Commit 15dfd7e has been approved by |
…ielb1 Be more obvious when suggesting dereference Include `&` span when suggesting dereference on a span that is already a reference: ``` error: non-reference pattern used to match a reference (see issue #42640) --> dont-suggest-dereference-on-arg.rs:16:19 | 16 | .filter(|&(ref a, _)| foo(a)) | ^^^^^^^^^^^ help: consider using: `&&(ref k, _)` | = help: add #![feature(match_default_bindings)] to the crate attributes to enable ``` Fix#45925.
bors
commented
Nov 26, 2017
bors
commented
Nov 26, 2017
☀️ Test successful - status-appveyor, status-travis |
Include
&span when suggesting dereference on a span that is already a reference:Fix#45925.