about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2021-04-20Change uses of never typeChristiaan Dirkx-196/+198
2021-04-20Replace `Void` with never typeChristiaan Dirkx-60/+44
2021-04-19Rollup merge of #84291 - RalfJung:thread-local-const-init, r=alexcrichtonDylan DPC-1/+1
fix aliasing violations in thread_local_const_init Fixes https://github.com/rust-lang/rust/pull/83416#discussion_r615364774 r? `@alexcrichton` `@sfackler`
2021-04-19Rollup merge of #84256 - tspiteri:pretty-minus-zero, r=workingjubileeDylan DPC-4/+4
doc: use U+2212 for minus sign in floating-point -0.0 remarks Also remove plus sign in `-0.0 == +0.0` to make it a valid expression.
2021-04-19Fix `vxworks` compilation errorsChristiaan Dirkx-10/+23
2021-04-19Move `sys::vxworks` code to `sys::unix`Christiaan Dirkx-213/+64
2021-04-19Stablize {HashMap,BTreeMap}::into_{keys,values}Folyd-18/+12
2021-04-19Update library/std/src/primitive_docs.rsTrevor Spiteri-2/+2
Co-authored-by: Jubilee <46493976+workingjubilee@users.noreply.github.com>
2021-04-18Auto merge of #78880 - CDirkx:not_supported, r=joshtriplettbors-54/+77
Add `Unsupported` to `std::io::ErrorKind` I noticed a significant portion of the uses of `ErrorKind::Other` in std is for unsupported operations. The notion that a specific operation is not available on a target (and will thus never succeed) seems semantically distinct enough from just "an unspecified error occurred", which is why I am proposing to add the variant `Unsupported` to `std::io::ErrorKind`. **Implementation**: The following variant will be added to `std::io::ErrorKind`: ```rust /// This operation is unsupported on this platform. Unsupported ``` `std::io::ErrorKind::Unsupported` is an error returned when a given operation is not supported on a platform, and will thus never succeed; there is no way for the software to recover. It will be used instead of `Other` where appropriate, e.g. on wasm for file and network operations. `decode_error_kind` will be updated to decode operating system errors to `Unsupported`: - Unix and VxWorks: `libc::ENOSYS` - Windows: `c::ERROR_CALL_NOT_IMPLEMENTED` - WASI: `wasi::ERRNO_NOSYS` **Stability**: This changes the kind of error returned by some functions on some platforms, which I think is not covered by the stability guarantees of the std? User code could depend on this behavior, expecting `ErrorKind::Other`, however the docs already mention: > Errors that are `Other` now may move to a different or a new `ErrorKind` variant in the future. It is not recommended to match an error against `Other` and to expect any additional characteristics, e.g., a specific `Error::raw_os_error` return value. The most recent variant added to `ErrorKind` was `UnexpectedEof` in `1.6.0` (almost 5 years ago), but `ErrorKind` is marked as `#[non_exhaustive]` and the docs warn about exhaustively matching on it, so adding a new variant per se should not be a breaking change. The variant `Unsupported` itself could be marked as `#[unstable]`, however, because this PR also immediately uses this new variant and changes the errors returned by functions I'm inclined to agree with the others in this thread that the variant should be insta-stabilized.
2021-04-18fix aliasing violations in thread_local_const_initRalf Jung-1/+1
2021-04-18Bump to 1.53.0CDirkx-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-04-18Fix test `metadata_access_times` to also check for `Unsupported`Christiaan Dirkx-1/+3
2021-04-18Rename `NotSupported` to `Unsupported`Christiaan Dirkx-18/+29
2021-04-18Use `NotSupported` in more placesChristiaan Dirkx-47/+48
2021-04-18Bump since to 1.52.0CDirkx-1/+1
2021-04-18Update `decode_error_kind` to decode os errors to `NotSupported`Christiaan Dirkx-0/+4
2021-04-18Add and insta-stabilize `std::io::ErrorKind::NotSupported`Christiaan Dirkx-6/+11
2021-04-18Auto merge of #84207 - SimonSapin:deprecate-core-raw, r=dtolnaybors-0/+1
Deprecate the core::raw / std::raw module It only contains the `TraitObject` struct which exposes components of wide pointer. Pointer metadata APIs are designed to replace this: https://github.com/rust-lang/rust/issues/81513
2021-04-16Add documentation to help people find `Ipv4Addr::UNSPECIFIED`Josh Triplett-0/+3
People looking for `INADDR_ANY` don't always find `Ipv4Addr::UNSPECIFIED`; add some documentation and an alias to help.
2021-04-16doc: use U+2212 for minus sign in floating-point -0.0 remarksTrevor Spiteri-4/+4
Also remove plus sign in `-0.0 == +0.0` to make it a valid expression.
2021-04-16Document the edition behavior for array.into_iter()Josh Stone-0/+50
2021-04-16Adjust docs and tests for new `IntoIterator` impl for arraysLukas Kalbertodt-19/+4
2021-04-16std: Add a variant of thread locals with const initAlex Crichton-49/+227
This commit adds a variant of the `thread_local!` macro as a new `thread_local_const_init!` macro which requires that the initialization expression is constant (e.g. could be stuck into a `const` if so desired). This form of thread local allows for a more efficient implementation of `LocalKey::with` both if the value has a destructor and if it doesn't. If the value doesn't have a destructor then `with` should desugar to exactly as-if you use `#[thread_local]` given sufficient inlining. The purpose of this new form of thread locals is to precisely be equivalent to `#[thread_local]` on platforms where possible for values which fit the bill (those without destructors). This should help close the gap in performance between `thread_local!`, which is safe, relative to `#[thread_local]`, which is not easy to use in a portable fashion.
2021-04-14Requires deprecated *and* deprecated_in_future, depending on what stage is ↵David Tolnay-1/+1
building
2021-04-14s/deprecated_in_future/deprecated/David Tolnay-1/+1
2021-04-15Deprecate the core::raw / std::raw moduleSimon Sapin-0/+1
It only contains the `TraitObject` struct which exposes components of wide pointer. Pointer metadata APIs are designed to replace this: https://github.com/rust-lang/rust/issues/81513
2021-04-15Rollup merge of #84177 - ehuss:join_paths-err, r=kennytmDylan DPC-1/+1
Fix join_paths error display. On unix, the error from `join_paths` looked like this: ``` path segment contains separator `58` ``` This PR changes it to look like this: ``` path segment contains separator `:` ```
2021-04-15Rollup merge of #82492 - CDirkx:sys_common_alloc, r=m-ou-seDylan DPC-8/+22
Move `std::sys_common::alloc` to new module `std::sys::common` https://github.com/rust-lang/rust/blob/6b56603e35b39c9f6cc76782330e5e415f9e43d5/library/std/src/sys_common/mod.rs#L7-L13 It was my impression that the goal for `std::sys` has changed from extracting it into a separate crate to making std work with features. However the fact remains that there is a lot of interdependence between `sys` and `sys_common`, this is because `sys_common` contains two types of code: - abstractions over the different platform implementations in `std::sys` (for example [`std::sys_common::mutex`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/mutex.rs)) - code shared between platforms (for example [`std::sys_common::alloc`](https://github.com/rust-lang/rust/blob/master/library/std/src/sys_common/alloc.rs)) This PR attempts to address this by adding a new module `common` to `std::sys` which will contain code shared between platforms, `alloc.rs` in this case but more can be moved over in the future.
2021-04-14Update documentationChristiaan Dirkx-5/+17
2021-04-14Move `std::sys_common::alloc` to `std::sys::common`Christiaan Dirkx-3/+5
2021-04-13BufWriter: improve safety commentTyson Nottingham-6/+10
2021-04-13Fix join_paths error display.Eric Huss-1/+1
2021-04-13BufWriter: simplify buffer drainingTyson Nottingham-5/+1
2021-04-13BufWriter: use #[cold] and less aggressive #[inline] hintsTyson Nottingham-1/+3
2021-04-13BufWriter: handle possibility of overflowTyson Nottingham-15/+39
2021-04-13BufWriter: optimize for write sizes less than buffer sizeTyson Nottingham-24/+32
Optimize for the common case where the input write size is less than the buffer size. This slightly increases the cost for pathological write patterns that commonly fill the buffer exactly, but if a client is doing that frequently, they're already paying the cost of frequent flushing, etc., so the cost is of this optimization to them is relatively small.
2021-04-13BufWriter: avoid using expensive Vec methodsTyson Nottingham-12/+75
We use a Vec as our internal, constant-sized buffer, but the overhead of using methods like `extend_from_slice` can be enormous, likely because they don't get inlined, because `Vec` has to repeat bounds checks that we've already done, and because it makes considerations for things like reallocating, even though they should never happen.
2021-04-13BufWriter: apply #[inline] / #[inline(never)] optimizationsTyson Nottingham-24/+66
Ensure that `write` and `write_all` can be inlined and that their commonly executed fast paths can be as short as possible. `write_vectored` would likely benefit from the same optimization, but I omitted it because its implementation is more complex, and I don't have a benchmark on hand to guide its optimization.
2021-04-13Rollup merge of #84084 - m-ou-se:stabilize-zero, r=scottmcmDylan DPC-1/+0
Stabilize duration_zero. FCP here: https://github.com/rust-lang/rust/issues/73544#issuecomment-817201305
2021-04-13Auto merge of #82992 - philippeitis:stabilize_bufreader_seek_relative, ↵bors-1/+1
r=workingjubilee Stabilize `bufreader_seek_relative` This PR marks `BufReader::seek_relative` as stable - the associated issue, #31100, has passed the final comment period without any issues, and from what I understand, the only thing left to stabilize this is to submit a PR marking the method as stable. Closes #31100.
2021-04-12Auto merge of #82918 - Manishearth:edition-2015-warn, r=oli-obkbors-0/+1
Turn old edition lint (anonymous-parameters) into warn-by-default on 2015 This makes `anonymous_parameters` <s>and `keyword_idents` </s>warn-by-default on the 2015 edition. I would also like to do this for `absolute_paths_not_starting_with_crate`, but I feel that case is slightly less clear-cut. Note that this only affects code on the 2015 edition, such code is illegal in future editions anyway. This was spurred by https://github.com/dtolnay/syn/issues/972: old edition syntax breaks tooling (like syn), and while the tooling should be free to find its balance on how much to support prior editions, it does seem like we should be nudging such code towards the newer edition, and we can do that by turning this Allow lint into a Warn. In general, I feel like migration lints from an old edition should be made Warn after a year or so, and idiom lints for the new edition should be made Warn after a couple months. cc `@m-ou-se,` this is for stuff from the 2015-2018 migration but you might be interested.
2021-04-12Auto merge of #83776 - jyn514:update-stdarch-docs, r=Amanieubors-14/+8
Update stdarch submodule (to before it switched to const generics) https://github.com/rust-lang/rust/pull/83278#issuecomment-812389823: This unblocks #82539. Major changes: - More AVX-512 intrinsics. - More ARM & AArch64 NEON intrinsics. - Updated unstable WASM intrinsics to latest draft standards. - std_detect is now a separate crate instead of a submodule of std. I double-checked and the first use of const generics looks like https://github.com/rust-lang/stdarch/commit/8d5017861ed594a2baf169e632379862d516e013, which isn't included in this PR. r? `@Amanieu`
2021-04-12Turn old edition lints (anonymous-parameters, keyword-idents) into ↵Manish Goregaokar-0/+1
warn-by-default on 2015
2021-04-12Stabilize duration_zero.Mara Bos-1/+0
2021-04-12Update stdarch submodule (to before it switched to const generics)Joshua Nelson-14/+8
This also includes a cherry-pick of https://github.com/rust-lang/stdarch/commit/ec1461905b421cf0c56adeebb49bbf55bb33fd17 and https://github.com/rust-lang/stdarch/pull/1108 to fix a build failure. It also adds a re-export of various macros to the crate root of libstd - previously they would show up automatically because std_detect was defined in the same crate.
2021-04-12Rollup merge of #84094 - tmiasko:remove-fixed-size-array, r=m-ou-seDylan DPC-1/+0
Remove FixedSizeArray Remove `FixedSizeArray` trait, it has been superseded by const generics. Closes #27778.
2021-04-11Clarify the guarantees that ThreadId does and doesn't make.Laurence Tratt-4/+7
The existing documentation does not spell out whether `ThreadId`s are unique during the lifetime of a thread or of a process. I had to examine the source code to realise (pleasingly!) that they're unique for the lifetime of a process. That seems worth documenting clearly, as it's a strong guarantee. Examining the way `ThreadId`s are created also made me realise that the `as_u64` method on `ThreadId` could be a trap for the unwary on those platforms where the platform's notion of a thread identifier is also a 64 bit integer (particularly if they happen to use a similar identifier scheme to `ThreadId`). I therefore think it's worth being even clearer that there's no relationship between the two.
2021-04-11Remove FixedSizeArrayTomasz Miąsko-1/+0
2021-04-10clean up example on read_to_stringSteve Klabnik-1/+2
This is the same thing, but simpler.
2021-04-05Rollup merge of #83831 - AngelicosPhosphoros:issue-77583-inline-for-ip, ↵Dylan DPC-0/+3
r=m-ou-se Add `#[inline]` to IpAddr methods Add some inlines to trivial methods of IpAddr Closes https://github.com/rust-lang/rust/issues/77583