-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Tracking Issue for RFC 2930 (read-buf) #78485
Comments
( cc @rust-lang/libs ) |
I'm interested in working on this. @rustbot claim |
I am slightly confused by the API of edit: probably I should ask this on zulip instead of github |
It would return |
I would have expected it to return |
Sure, that makes sense. |
@drmeepster are you still working on this? |
Yeah, I am. Although I'm currently working on #79607 because I needed it for this. |
Okay, I can continue working on this now that we have |
I have a PR to add an |
Have we considered extending This came up because I'm looking into fixing some UB in rayon, which is passing around uninitialized Going further, it would also be interesting to see if we could rewrite |
I made very similar points here: https://internals.rust-lang.org/t/readbuf-as-part-of-rust-edition-2021/14256/9?u=djc |
Note that we now have a |
…nic, r=dtolnay Don't panic in `<BorrowedCursor as io::Write>::write` Instead of panicking if the BorrowedCursor does not have enough capacity for the whole buffer, just return a short write, [like `<&mut [u8] as io::Write>::write` does](https://doc.rust-lang.org/src/std/io/impls.rs.html#349). (cc `@ChayimFriedman2` rust-lang#78485 (comment)) (I'm not sure if this needs an ACP? since it's not changing the "API", just what the function does)
…c, r=dtolnay Don't panic in `<BorrowedCursor as io::Write>::write` Instead of panicking if the BorrowedCursor does not have enough capacity for the whole buffer, just return a short write, [like `<&mut [u8] as io::Write>::write` does](https://doc.rust-lang.org/src/std/io/impls.rs.html#349). (cc `@ChayimFriedman2` rust-lang#78485 (comment)) (I'm not sure if this needs an ACP? since it's not changing the "API", just what the function does)
Don't panic in `<BorrowedCursor as io::Write>::write` Instead of panicking if the BorrowedCursor does not have enough capacity for the whole buffer, just return a short write, [like `<&mut [u8] as io::Write>::write` does](https://doc.rust-lang.org/src/std/io/impls.rs.html#349). (cc `@ChayimFriedman2` rust-lang/rust#78485 (comment)) (I'm not sure if this needs an ACP? since it's not changing the "API", just what the function does)
The
but the very next paragraph:
Looking at the actual implementations makes it obvious that they mostly pass-through and grab slices from the underlying |
Does Also related to @the8472's comment, docs need examples. |
Don't panic in `<BorrowedCursor as io::Write>::write` Instead of panicking if the BorrowedCursor does not have enough capacity for the whole buffer, just return a short write, [like `<&mut [u8] as io::Write>::write` does](https://doc.rust-lang.org/src/std/io/impls.rs.html#349). (cc `@ChayimFriedman2` rust-lang/rust#78485 (comment)) (I'm not sure if this needs an ACP? since it's not changing the "API", just what the function does)
There is something "fun" with I don't know if this is expected and it is probably useful, but it might be surprising if some implementations start doing that. In fact,
Something more problematic is that it is impossible to write a correct |
Tbh, I think |
Don't panic in `<BorrowedCursor as io::Write>::write` Instead of panicking if the BorrowedCursor does not have enough capacity for the whole buffer, just return a short write, [like `<&mut [u8] as io::Write>::write` does](https://doc.rust-lang.org/src/std/io/impls.rs.html#349). (cc `@ChayimFriedman2` rust-lang/rust#78485 (comment)) (I'm not sure if this needs an ACP? since it's not changing the "API", just what the function does)
It would be great to have a final word from libs-team on this:
I don't about Windows at all but on Unix at least I don't think this is possible. Can you link such an implementation ? |
See the post above for why this is nominated.
Neither the Windows API nor the documentation guarantees that no bytes will be read in an error case. One documented case is pipes in message mode:
To be clear, I'd have to check if we actually do handle this (I suspect not) but if we're going strictly by the |
Does this case really matter? The The example you give is very similar to the |
The Maybe swallowing any error is fine. But I think in an ideal world we'd have some way for the user to access this information. |
We discussed this in the libs-api meeting today. We agree that this can be surprising behavior, but don't see a good way to change the API to avoid it. Our conclusion was to update the documentation to say that returning an error after reading some bytes is allowed, but strongly discouraged. |
Maybe the return type should be |
I disagree that the signature of The problem comes in because a default implementation of |
On internals.r-l.o, keepsimple1 commented that they didn't realise that Could you update the summary to include something like: This is now called Thanks! |
I've added a note in the summary, hopefully that should help. |
…gjubilee Fix `read_buf` uses in `std` Following lib-team decision here: rust-lang#78485 (comment) Guard against the pathological behavior of both returning an error and performing a read.
Rollup merge of rust-lang#125404 - a1phyr:fix-read_buf-uses, r=workingjubilee Fix `read_buf` uses in `std` Following lib-team decision here: rust-lang#78485 (comment) Guard against the pathological behavior of both returning an error and performing a read.
This is a tracking issue for the RFC "2930" (rust-lang/rfcs#2930).
The feature gate for the issue is
#![feature(read_buf)]
.This is now called
BorrowedBuf
rather thanReadBuf
.About tracking issues
Tracking issues are used to record the overall progress of implementation.
They are also used as hubs connecting to other relevant issues, e.g., bugs or open design questions.
A tracking issue is however not meant for large scale discussion, questions, or bug reports about a feature.
Instead, open a dedicated issue for the specific matter and add the relevant feature gate label.
Steps
read_buf_vectored
,ReadBufs
).rustc_must_implement_one_of
, which is a language-observable thing, and thus needs some amount of oversight/documentation about that as a prerequisite of stabilization.Unresolved Questions
read_buf
return the number of bytes read likeread
does or should theReadBuf
track it instead? Some operations, like checking for EOF, are a bit simpler ifread_buf
returns the value, but the confusion around what is and is not trustworthy is worrysome for unsafe code working withRead
implementations.assume_init
be named?&mut ReadBuf
to prevent unexpected swapping of the caller-providedReadBuf
?BufWriter
copy_to specialization with the unstableread_buf
feature #93305Implementation history
The text was updated successfully, but these errors were encountered: