-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Some de-~[] work in std::io #13165
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Some de-~[] work in std::io #13165
Conversation
Would it make sense to introduce a |
I grow slightly worried about all of this removal of I'm basically worried about possibly unnecessary churn. @nick29581, do you think that |
@alexcrichton And, of course, if the client does want to be able to push/pop, they'd have to move the |
@kballard, that is not true, in a DST world Moving from |
Why would we want to forbid anyone from pushing to a vector returned by |
We wouldn't forbid it, DST provides cheap transitions between |
@alexcrichton Ok you're right, I was confused and was thinking that the data was stored inline. But it's stored in a separate allocation, which means it can be moved between In any case, I am not opposed to returning |
@alexcrichton so my issue is that, right now, in my build.. i use That being said, I don't think it's fair (or right) to pretty much put this on users, pending the change of Should users have to wrangle with either 1) warning spam or 2) workarounds/massaging in their code (as I did) in order to continue using |
@olsonjeffery, the Again, I don't want us to get ahead of ourselves. I have not heard from anyone implementing DST as to whether removing
Definitely not 1 (it's turned off), and I would very much like to deliberately change
This is what I've been saying about not changing to |
BTW, it's easy to make DST Removing OTOH to make it efficient it means that you are forced to round up all |
I think the transition from current |
@huonw, I'm trying to emphasize that no one here is the one implementing DST, so no one knows for sure that we should remove |
I think It's also a significant performance improvement right now, and switching to |
I can understand wanting to avoid the churn and avoiding a backwards compatibility hazard, but I'm not really convinced that |
@alexcrichton Sorry for the late reply, been away from work. I was kind of thinking the same thing myself (whether it is necessary to totally kill [T] now). To be honest, I don't know the answer. I haven't got near to that stage in the implementation. Currently I am adding unsized/sized knowledge into the compiler and that is totally unaffected. My guess is that we don't need to, but it might make things a little bit easier. I would be happy to wait and see - that is do nothing for now and only remove ~[T] when/if we know we have to. In general I prefer to move from one solution to another, rather than from one solution to an intermediate encoding to a second solution since I think the risk of missing something is lower. |
(Any response to #13165 (comment)? Functions using |
@huonw I agree. I don't see any benefit to converting to |
@huonw I hesitate to voice an opinion on library design since I have zero experience there. From the language POV, I would prefer to see [T] used wherever possible (in preference to Vec) because if we provide a nice syntax we should strive to make it the default and avoid the situation where there are non-obvious choices to make (or worse, choices based only on the aesthetic opinions of the user). It seems that the story is [T] if the size is fixed and Vec if the size can change, but then the cases you point out are difficult because one can't know the size-mutability intent ahead of time and we should expose the implementation detail that Vec is used internally to construct the result. We could have two of each method, one returning Vec, one [T], but that seems really bad. Perhaps the ideal situation is that we return [T] and if the caller changes that immediately to Vec then somehow, magically that is free. Not sure how that could work though. Without such magic, returning Vec seems better since it is more general, but then I have the philosophical objection. Sigh. So, that was a long-winded way of saying 'I don't know'. |
The way I see it, the only time a Of course the philosophical objects remain. One way to think of this would be flipping it around: if we only had I would think that we wouldn't do that (because makes the function slower, due to needing a shrink-to-fit to return, and penalises those cases when the caller does want to modify it), and that we would only change things to |
@nick29581: If we use lots of |
@thestinger Ideally, once DST lands, nobody will ever use |
Can we move forward on this and just land it? If necessary, we can convert back to (I'm keen to put |
Rebased |
There's a little more allocation here and there now since from_utf8_owned can't be used with Vec.
`Reader`, `Writer`, `MemReader`, `MemWriter`, and `MultiWriter` now work with `Vec<u8>` instead of `~[u8]`. This does introduce some extra copies since `from_utf8_owned` isn't usable anymore, but I think that can't be helped until `~str`'s representation changes.
Properly handle break resolution inside non-breakable expressions We now diagnose invalid `continue` expressions and properly handle things like `async` blocks which prevent labels from resolving further. Cleaned this up since `label_break_value` is on the way to stabilization in rust (🎉 finally) and we weren't handling breaks for blocks properly yet.
chore: fix some comments fix some comments *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: none
Reader
,Writer
,MemReader
,MemWriter
, andMultiWriter
now work withVec<u8>
instead of~[u8]
. This does introduce some extra copies sincefrom_utf8_owned
isn't usable anymore, but I think that can't be helped until~str
's representation changes.