Uh oh!
There was an error while loading. Please reload this page.
Improve reference cast help message - #37375
Conversation
rust-highfive
commented
Oct 24, 2016
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
7ddd19f to
329e1f5Compareeddyb
commented
Oct 24, 2016
You completely changed the meaning though, now it's bad if the user wanted to do the pointer thing. |
GuillaumeGomez
commented
Oct 24, 2016
But at least it's not incorrect anymore. |
@GuillaumeGomez: I'm not sure, but wouldn't your patch suggest dereferencing the pointer also in the following case: let _ = &String::new()asusize;Here, the original message is more accurate, I think. |
In @TimNN's example, the original message clearly makes more sense. In the example from #37338, there is genuine ambiguity about which one the user wanted to do, but I would argue that the new suggestion is probably better because I suspect that the deref case is the more common one. Would it makes sense to check the |
eddyb
commented
Oct 24, 2016
I'd argue that only |
GuillaumeGomez
commented
Oct 24, 2016
@TimNN: Well saw and not well saw at the same time. In this case, you should have to explicitly cast into a pointer before casting to usize. However, it just puts under the light a big issue: the compiler cannot guess what the user intends to do in some cases and only provide the simplest solution. In this case, more people will certainly think that you just want to get the length and you put @fhartwig: Still difficult. But we could provide both helps. What do you think about this @eddyb? |
eddyb
commented
Oct 24, 2016
@GuillaumeGomez IMO having both is more confusing. |
GuillaumeGomez
commented
Oct 24, 2016
Ok, I'll update it this way then. |
@GuillaumeGomez, I hadn't seen that this PR was already out, so I took a stab at it as well. I still feel there's some value in PR #37442, as it handles the case @TimNN pushed forward as it is now, and specializes the cases of For a given file: fnmain(){vec![0.0].iter().map(|s| s asi16).collect::<Vec<i16>>();let _ = &String::new()asusize;}PR #37442 outputs: |
GuillaumeGomez
commented
Oct 28, 2016
@estebank: I still need to update it anyway. I intend to do it this week-end. |
329e1f5 to
ddd00f7CompareGuillaumeGomez
commented
Oct 29, 2016
Updated. |
Travis failure looks unrelated. |
GuillaumeGomez
commented
Nov 2, 2016
I restart it. |
GuillaumeGomez
commented
Nov 6, 2016
cc @eddyb |
eddyb
commented
Nov 6, 2016
You seem to have removed too many messages. |
sophiajt
commented
Nov 8, 2016
Agree with @eddyb - why remove the help messages? |
GuillaumeGomez
commented
Nov 8, 2016
@jonathandturner: It comes after a discussion between @eddyb and me. Since a lot of messages were incorrect in some cases, it should be better to just remove them. However, after the last messages, I think I misunderstood him. Any further explanation would be appreciated. :) |
eddyb
commented
Nov 8, 2016
What I mean is only providing the "pointer to integer" help if |
d4c7a85 to
5c341b1CompareGuillaumeGomez
commented
Nov 10, 2016
Updated. |
There was a problem hiding this comment.
I don't think you need to change anything in this file.
There was a problem hiding this comment.
These should still emit the help. It's only when that usize is replaced with another type that it's wrong.
There was a problem hiding this comment.
How could this have disappeared?
5c341b1 to
157acc8CompareGuillaumeGomez
commented
Nov 10, 2016
@eddyb: Didn't pay attention to the tests I updated. Fixed now. |
eddyb
commented
Nov 10, 2016
@GuillaumeGomez Can you add non- |
That's another debate I think haha. If you can imagine something weird, someone will do something weirder. |
9bda5fb to
3f0c2d2CompareGuillaumeGomez
commented
Nov 16, 2016
cc @eddyb |
arielb1
commented
Nov 16, 2016
|
3f0c2d2 to
37903bfComparearielb1
commented
Nov 16, 2016
@bors r+ |
bors
commented
Nov 16, 2016
📌 Commit 37903bf has been approved by |
bors
commented
Nov 17, 2016
⌛ Testing commit 37903bf with merge f22fdb0... |
Improve reference cast help message Fixes#37338.
Fixes#37338.