-
Notifications
You must be signed in to change notification settings - Fork 13.1k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
std: IntoInnerError into_parts, NoStorageSpace #78689
Conversation
The lack of this is surprising. Also I am about to want it for an example. This has to be insta-stable because we can't sensibly have a different set of ErrorKinds depending on a std feature flag. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
In particular, IntoIneerError only currently provides .error() which returns a reference, not an owned value. This is not helpful and means that a caller of BufWriter::into_inner cannot acquire an owned io::Error which seems quite wrong. I have made this insta-stable because I think it ought to be very uncontroversial. It doesn't involve promising new facts about the underlying implementation; it just gives a better access to the facts which are already implied. The lack of the usual `into_parts` seems simply an oversight. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
r? @m-ou-se (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect this to be two different PRs, especially since both of these are insta-stable. That said, I'm not on libs, so the team may feel differently.
/// The underlying storage (typically, a filesystem) is full. | ||
/// | ||
/// This does not include out of quota errors. | ||
#[stable(feature = "io_error_no_storage_space", since = "1.51.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.47 is stable and 1.49 is the current nightly.
#[stable(feature = "io_error_no_storage_space", since = "1.51.0")] | |
#[stable(feature = "io_error_no_storage_space", since = "1.49.0")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I'm a bit pessimistic about when this might go in but if it seems right in principle I will change it obviously.
@@ -199,6 +204,7 @@ impl ErrorKind { | |||
ErrorKind::TimedOut => "timed out", | |||
ErrorKind::WriteZero => "write zero", | |||
ErrorKind::Interrupted => "operation interrupted", | |||
ErrorKind::NoStorageSpace => "no storage space", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$ errno ENOSPC
ENOSPC 28 No space left on device
ErrorKind::NoStorageSpace => "no storage space", | |
ErrorKind::NoStorageSpace => "no space left on device", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. I'm happy to change the message to be identical to the traditional Unix one if that seems better. But most of the existing messages do not mirror the traditional Unix ones.
If it would be two PRs, one of them would depend on the other. I don't know what the usual way is to handle that situation in rust-lang. I'm happy to go with whatever the usual approach is, obviously. Thanks for the review, anyway. Let's see what the libs folk think. |
If you use a local buffer instead of a let mut not_enough_space = [0u8; 10];
let mut stream = BufWriter::new(not_enough_space.as_mut());
write!(stream, "this does not fit entirely in the array").unwrap();
... So then you don't need (If you think |
Mara Bos writes ("Re: [rust-lang/rust] std: IntoInnerError into_parts, NoStorageSpace (#78689)"):
If you use a local buffer instead of a File, you can make the example cross
platform:
let mut not_enough_space = [0u8; 10];
let mut stream = BufWriter::new(not_enough_space.as_mut());
write!(stream, "this does not fit entirely in the array").unwrap();
...
So then you don't need ErrorKind::NoStorageSpace here.
Thanks. I don't know why I didn't think of that. Too much experience
of C I guess.
I notice that this produces ErrorKind::WriteZero. I think that should
be documented, so I will send probably another MR for that.
(If you think ErrorKind::NoStorageSpace is useful by itself, please open a
separate PR for that.)
Willdo.
Thanks,
Ian.
…--
Ian Jackson <ijackson@chiark.greenend.org.uk> These opinions are my own.
Pronouns: they/he. If I emailed you from @fyvzl.net or @evade.org.uk,
that is a private address which bypasses my fierce spamfilter.
|
@ijackson Ping from triage! Any updates on this? |
This MR will be confusing If I reuse it for either of the two halves. So I am going to close it and redo this with two separate MRs for the two halves. Thanks. |
…-ou-se Provide IntoInnerError::into_parts Hi. This is an updated version of the IntoInnerError bits of my previous portmanteau MR rust-lang#78689. Thanks to `@jyn514` and `@m-ou-se` for helpful comments there. I have made this insta-stable since it seems like it will probably be uncontroversial, but that is definitely something that someone from the libs API team should be aware of and explicitly consider. I included a tangentially-related commit providing documentation of the buffer full behaviiour of `&mut [u8] as Write`; the behaviour I am documenting is relied on by the doctest for `into_parts`.
Hi. I was doing something with std and
BufWriterr
and I discovered that after getting anIntoInnerError
I wasn't able to get an owned copy of the containedio::Error
. That seemed wrong, so I set about making an MR to fix it. That is the 2nd commit here.While doing this I wanted to write a doctest. I wasn't able to think of a reliable portable way of provoking a convenient io error but on Linux at least we have
/dev/full
so I used that. I think I have marked the doctest with the appropriate attribute. I guess I'll see what the CI says.But the doctest wants to say something about the actual error, and unaccountably
ErrorKind
lacks a variant corresponding toENOSPC
. Given that the docs say that existing errors of kindOther
may change into specific errors, I thought this was not a breaking change.I have made both of these things insta-stable. That will definitely need an fcp at least, and also this is my first attempt to (1) do a platform-specific doctest and (2) provide an insta-stable method on something in std, so it will need some review from appropriate people!
Additionally, since I know nothing about Windows I have not added anything to do with
ErrorKind::NoStorageSpace
there. I don't know if this ought to be a blocker. My git grep also found some stuff to do with vxworks; I don't know if that hasENOSPC
.Thanks for your attention.