Uh oh!
There was an error while loading. Please reload this page.
Suggest using slice when encountering let x = ""[..]; - #46249
Conversation
rust-highfive
commented
Nov 24, 2017
r? @eddyb (rust_highfive has picked a reviewer for you, use r? to override) |
eddyb
commented
Nov 24, 2017
I don't think the index type matters, we should just not check it and just emit the suggestion. |
There was a problem hiding this comment.
You need to add //~ ERROR comments. Ui tests work like compile-fail now
There was a problem hiding this comment.
Why just for assignments and not all the cases in the test?
There was a problem hiding this comment.
The other cases in the test go through type check instead. I'll see if I can expand #46256 to also suggest in these cases. I included all the cases originally mentioned in order to make sure we don't regress in any of the cases (without noticing).
134889a to
3b56558Compareestebank
commented
Nov 25, 2017
@eddyb I believe you were right so removed the index type check. |
r? @nikomatsakis I still feel this is much more specific than it should be, but I don't have any good suggestions, other than perhaps that In general, both deref and indexing could use a suggestion to borrow the resulting lvalue. |
There was a problem hiding this comment.
this looks dubious. Could you look into this?
There was a problem hiding this comment.
Yeah, I noticed that too. Still digging.
There was a problem hiding this comment.
it's also already the case on nightly. Feel free to ignore this and open an issue.
This feels hacky to me, but I don't see any better way of implementing this (the rhs of locals is an lvalue, so checks based on it being an rvalue won't quite work). btw, you should be checking that the problem type is a slice or string - if the return type is a struct or trait object, you don't want the error message to mention "slices". |
arielb1
commented
Nov 27, 2017
OTOH, having an |
estebank
commented
Nov 27, 2017
@arielb1 reworded. |
arielb1
commented
Nov 27, 2017
@bors r+ rollup |
bors
commented
Nov 27, 2017
📌 Commit fa44927 has been approved by |
Suggest using slice when encountering `let x = ""[..];` Fixrust-lang#26319.
Fix#26319.