about summary refs log tree commit diff
path: root/library/std/src/io
AgeCommit message (Collapse)AuthorLines
2025-01-26Test pipes also when not running on Windows and Linux simultaneouslyTobias Bucher-1/+1
Fixes https://github.com/rust-lang/rust/pull/135635#pullrequestreview-2574184488.
2025-01-26Update `std::io::{pipe, PipeReader, PipeWriter}` docs the new locationTobias Bucher-16/+20
Also create a section "Platform-specific behavior", don't hide required imports for code examples.
2025-01-26Move `std::io::pipe` code into its own fileTobias Bucher-272/+277
2025-01-25Rollup merge of #135948 - bjorn3:update_emscripten_std_tests, r=Mark-SimulacrumJacob Pratt-2/+1
Update emscripten std tests This disables a bunch of emscripten tests that test things emscripten doesn't support and re-enables a whole bunch of tests which now work just fine on emscripten. Tested with `EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" ./x.py test library/ --target wasm32-unknown-emscripten`.
2025-01-25Improve and expand documentation of pipesJosh Triplett-8/+14
- Simplify some of the language - Minor grammar fixes - Don't imply that pipes *only* work across multiple processes; instead, *suggest* that they're typically used across two or more separate processes. - Specify that portable applications cannot use multiple readers or multiple writers for messages larger than a byte, due to potential interleaving. - Remove no-longer-referenced footnote URLs.
2025-01-24Remove a bunch of emscripten test ignoresbjorn3-2/+0
They are either outdated as emscripten now supports i128 or they are subsumed by #[cfg_attr(not(panic = "unwind"), ignore]
2025-01-24Fix testing of the standard library with Emscriptenbjorn3-0/+1
This does need EMCC_CFLAGS="-s MAXIMUM_MEMORY=2GB" avoid several OOMs.
2025-01-17Move `std::pipe::*` into `std::io`Jiahao XU-0/+266
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2025-01-11Add inherent versions of MaybeUninit methods for slicesltdk-1/+1
2025-01-10Use `NonNull::without_provenance` within the standard librarySamuel Tardieu-3/+4
This API removes the need for several `unsafe` blocks, and leads to clearer code.
2025-01-08update version placeholdersPietro Albini-2/+2
2024-12-21Avoid short writes in LineWriterChris Denton-6/+21
Also update the tests to avoid testing implementation details.
2024-12-21Less unwrap() in documentationKornel-10/+15
2024-12-06Rollup merge of #130254 - GrigorenkoPV:QuotaExceeded, r=dtolnayMatthias Krüger-9/+9
Stabilize `std::io::ErrorKind::QuotaExceeded` Also drop "Filesystem" from its name. See #130190 for more info. FCP in #130190 cc #86442 r? `@dtolnay`
2024-12-06Rollup merge of #130209 - GrigorenkoPV:CrossesDevices, r=dtolnayMatthias Krüger-1/+1
Stabilize `std::io::ErrorKind::CrossesDevices` FCP in #130191 cc #86442 See #130191 for more info and a recap of what has happened up until now. TLDR: This had been FCP'd in December 2022 with some other `ErrorKind`s, but the stabilization got postponed due to some concerns voiced about several of the variants. However, the only concern ever voiced for this variant in particular was a wish to rename this to `NotSameDevice` analogous to Windows's `ERROR_NOT_SAME_DEVICE` (as opposed to Unix's `EXDEV`). This suggestion did not receive any support. So let's try to FCP this as is. r? libs-api
2024-12-01add isatty alias for is_terminalcod10129-0/+1
2024-11-26std: update internal uses of `io::const_error!`joboet-21/+21
2024-11-25std: expose `const_io_error!` as `const_error!`joboet-20/+36
ACP: rust-lang/libs-team#205 Tracking issue: #133448
2024-11-20Rollup merge of #130800 - bjoernager:const-mut-cursor, r=joshtriplettMatthias Krüger-2/+4
Mark `get_mut` and `set_position` in `std::io::Cursor` as const. Relevant tracking issue: #130801 The methods `get_mut` and `set_position` can trivially be marked as const due to #57349 being stabilised.
2024-11-14Rollup merge of #132790 - aDotInTheVoid:ioslice-asslice-rides-again, r=cuviperJubilee-0/+59
Add as_slice/into_slice for IoSlice/IoSliceMut. ACP: https://github.com/rust-lang/libs-team/issues/93 Tracking issue: #132818 Based on a623c5233ae7f6b540e5c00f2be02f40b33b0793 (CC `@mpdn)` and #111277 (CC `@Lucretiel).` Closes: #124659 Tracking Issue: TODO try-job: test-various try-job: dist-various-1 try-job: dist-various-2 r? libs
2024-11-09Add as_slice/into_slice for IoSlice/IoSliceMut.Alona Enraght-Moony-0/+59
Co-authored-by: Mike Pedersen <mike@mikepedersen.dk> Co-authored-by: Nathan West <Lucretiel@gmail.com>
2024-11-08update io::Error::into_inner to acknowlage io::Error::otherbinarycat-2/+4
2024-10-23Specialize `read_exact` and `read_buf_exact` for `VecDeque`Benoît du Garreau-0/+46
2024-10-15replace placeholder versionJosh Stone-17/+17
(cherry picked from commit 567fd9610cbfd220844443487059335d7e1ff021)
2024-10-10More clearly document Stdin::read_lineTim (Theemathas) Chirananthavat-1/+6
These are common pitfalls for beginners, so I think it's worth making the subtleties more visible.
2024-10-05Unbreak tidyPavel Grigorenko-5/+5
2024-10-05Stabilize `std::io::ErrorKind::QuotaExceeded`Pavel Grigorenko-5/+5
Also drop "Filesystem" from its name
2024-10-04Stabilize `BufRead::skip_until`okaneco-3/+1
2024-10-02Add `get_line` confusable to `Stdin::read_line()`Jaken Herman-0/+1
Add tests for addition of `#[rustc_confusables("get_line")]`
2024-09-30Rollup merge of #130914 - compiler-errors:insignificant-dtor, r=AmanieuTrevor Gross-0/+1
Mark some more types as having insignificant dtor These were caught by https://github.com/rust-lang/rust/pull/129864#issuecomment-2376658407, which is implementing a lint for some changes in drop order for temporaries in tail expressions. Specifically, the destructors of `CString` and the bitpacked repr for `std::io::Error` are insignificant insofar as they don't have side-effects on things like locking or synchronization; they just free memory. See some discussion on #89144 for what makes a drop impl "significant"
2024-09-29Fix std tests for wasm32-wasip2 targetNicola Krumschmidt-5/+6
2024-09-28Rollup merge of #125404 - a1phyr:fix-read_buf-uses, r=workingjubileeMatthias Krüger-16/+88
Fix `read_buf` uses in `std` Following lib-team decision here: https://github.com/rust-lang/rust/issues/78485#issuecomment-2122992314 Guard against the pathological behavior of both returning an error and performing a read.
2024-09-27Mark some more types as having insignificant dtorMichael Goulet-0/+1
2024-09-25Add tracking issue for io_error_inprogressnora-1/+1
2024-09-25Auto merge of #130803 - cuviper:file-buffered, r=joshtriplettbors-1/+29
Add `File` constructors that return files wrapped with a buffer In addition to the light convenience, these are intended to raise visibility that buffering is something you should consider when opening a file, since unbuffered I/O is a common performance footgun to Rust newcomers. ACP: https://github.com/rust-lang/libs-team/issues/446 Tracking Issue: #130804
2024-09-24Mark 'get_mut' and 'set_position' in 'std::io::Cursor' as const;Gabriel Bjørnager Jensen-2/+4
2024-09-24Pre-allocate buffers in `File::open_buffered` and `create_buffered`Josh Stone-1/+29
2024-09-24add InProgress ErrorKind gated behind io_error_inprogress featureAviram Hassan-0/+7
Co-authored-by: David Tolnay <dtolnay@gmail.com> Co-authored-by: nora <48135649+Noratrieb@users.noreply.github.com>
2024-09-23Add a comment to `Read::read_buf`Benoît du Garreau-0/+2
2024-09-23Add testsBenoît du Garreau-0/+63
2024-09-23Fix `io::default_read_to_end` uses of `read_buf`Benoît du Garreau-10/+14
2024-09-23Fix `io::BufReader` uses of `read_buf`Benoît du Garreau-2/+4
2024-09-23Fix `io::Take::read_buf`Benoît du Garreau-4/+5
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-16/+15
2024-09-21wait for two short reads before uncapping the max read sizeThe 8472-3/+13
for disk IO: 1st short read = probably at end of file 2nd short read = confirming that it's indeed EOF
2024-09-20[Clippy] Remove final std paths for diagnostic itemGnomedDev-0/+1
2024-09-15Rollup merge of #130042 - lolbinarycat:bufreaker_peek_eof, r=AmanieuStuart Cook-4/+12
properly handle EOF in BufReader::peek previously this would cause an infinite loop due to it being unable to read `n` bytes.
2024-09-11Stabilize `std::io::ErrorKind::CrossesDevices`Pavel Grigorenko-1/+1
2024-09-10Auto merge of #130025 - Urgau:missing_docs-expect, r=petrochenkovbors-0/+1
Also emit `missing_docs` lint with `--test` to fulfil expectations This PR removes the "test harness" suppression of the `missing_docs` lint to be able to fulfil `#[expect]` (expectations) as it is now "relevant". I think the goal was to maybe avoid false-positive while linting on public items under `#[cfg(test)]` but with effective visibility we should no longer have any false-positive. Another possibility would be to query the lint level and only emit the lint if it's of expect level, but that is even more hacky. Fixes https://github.com/rust-lang/rust/issues/130021 try-job: x86_64-gnu-aux
2024-09-09Rollup merge of #128316 - GrigorenkoPV:io_error_a_bit_more, r=dtolnayJubilee-16/+16
Stabilize most of `io_error_more` Sadly, venting my frustration with t-libs-api is not a constructive way to solve problems and get things done, so I will try to stick to stuff that actually matters here. - Tracking issue for this feature was opened 3 years ago: #86442 - FCP to stabilize it was completed 19(!!) months ago: https://github.com/rust-lang/rust/issues/86442#issuecomment-1368082102 - A PR with stabilization was similarly open for 19 months: #106375, but nothing ever came out of it. Presumably (it is hard to judge given the lack of communication) because a few of the variants still had some concerns voiced about them, even after the FCP. So, to highlight a common sentiment: > Maybe uncontroversial variants can be stabilised first and other variants (such as `QuotaExceeded` or `FilesystemLoop`) later? [^1] [^1]: https://github.com/rust-lang/rust/issues/106375#issuecomment-1435762236 > I would like to voice support stabilization of the uncontroversial variants. This would get those variants to stable and focus the discussion around the more controversial ones. I don't see any particular reason that all of these must be stabilized at the same time. [...] [^2] [^2]: https://github.com/rust-lang/rust/pull/106375#issuecomment-1742661555 > Maybe some less-controversial subset could be stabilized sooner? What’s blocking this issue from making progress? [^3] [^3]: https://github.com/rust-lang/rust/issues/86442#issuecomment-1691187483 (got 30 upvotes btw) (and no response) So this is exactly what this PR does. It stabilizes the non-controversial variants now, leaving just a few of them behind. Namely, this PR stabilizes: - `HostUnreachable` - `NetworkUnreachable` - `NetworkDown` - `NotADirectory` - `IsADirectory` - `DirectoryNotEmpty` - `ReadOnlyFilesystem` - `StaleNetworkFileHandle` - `StorageFull` - `NotSeekable` - `FileTooLarge` - `ResourceBusy` - `ExecutableFileBusy` - `Deadlock` - `TooManyLinks` - `ArgumentListTooLong` - `Unsupported` This PR does not stabilize: - `FilesystemLoop` - `FilesystemQuotaExceeded` - `CrossesDevices` - `InvalidFilename` Hopefully, this will allow us to move forward with this highly and long awaited addition to std, both allowing to still polish the less clear parts of it and not leading to stagnation. r? joshtriplett because they seem to be listed as a part of t-libs-api and were one of the most responsive persons previously