about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
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-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
2021-04-05Auto merge of #83864 - Dylan-DPC:rollup-78an86n, r=Dylan-DPCbors-1/+0
Rollup of 7 pull requests Successful merges: - #80525 (wasm64 support) - #83019 (core: disable `ptr::swap_nonoverlapping_one`'s block optimization on SPIR-V.) - #83717 (rustdoc: Separate filter-empty-string out into its own function) - #83807 (Tests: Remove redundant `ignore-tidy-linelength` annotations) - #83815 (ptr::addr_of documentation improvements) - #83820 (Remove attribute `#[link_args]`) - #83841 (Allow clobbering unsupported registers in asm!) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-04-05Rollup merge of #83820 - petrochenkov:nolinkargs, r=nagisaDylan DPC-1/+0
Remove attribute `#[link_args]` Closes https://github.com/rust-lang/rust/issues/29596 The attribute could always be replaced with `-C link-arg`, but cargo didn't provide a reasonable way to pass such flags to rustc. Now cargo supports `cargo:rustc-link-arg*` directives in build scripts (https://doc.rust-lang.org/cargo/reference/unstable.html#extra-link-arg), so this attribute can be removed.
2021-04-04Bump cfgsMark Rousskov-4/+1
2021-04-04Add `#[inline]` to IpAddr methodsAngelicosPhosphoros-0/+3
Add some inlines to trivial methods of IpAddr Closes https://github.com/rust-lang/rust/issues/77583
2021-04-03Remove attribute `#[link_args]`Vadim Petrochenkov-1/+0
2021-04-04Rollup merge of #83780 - matklad:doc-error-message, r=JohnTitorYuki Okushi-8/+15
Document "standard" conventions for error messages These are currently documented in the API guidelines: https://rust-lang.github.io/api-guidelines/interoperability.html#error-types-are-meaningful-and-well-behaved-c-good-err I think it makes sense to uplift this guideline (in a milder form) into std docs. Printing and producing errors is something that even non-expert users do frequently, so it is useful to give at least some indication of what a typical error message looks like.
2021-04-04Rollup merge of #82487 - CDirkx:const-socketaddr, r=m-ou-seYuki Okushi-10/+21
Constify methods of `std::net::SocketAddr`, `SocketAddrV4` and `SocketAddrV6` The following methods are made unstable const under the `const_socketaddr` feature (https://github.com/rust-lang/rust/issues/82485): ```rust // std::net impl SocketAddr { pub const fn ip(&self) -> IpAddr; pub const fn port(&self) -> u16; pub const fn is_ipv4(&self) -> bool; pub const fn is_ipv6(&self) -> bool; } impl SocketAddrV4 { pub const fn ip(&self) -> IpAddr; pub const fn port(&self) -> u16; } impl SocketAddrV6 { pub const fn ip(&self) -> IpAddr; pub const fn port(&self) -> u16; pub const fn flowinfo(&self) -> u32; pub const fn scope_id(&self) -> u32; } ``` Note: `SocketAddrV4::ip` and `SocketAddrV6::ip` use pointer casting and depend on the unstable feature `const_raw_ptr_deref`
2021-04-02Rollup merge of #83771 - asomers:stack_overflow_freebsd, r=dtolnayDylan DPC-7/+16
Fix stack overflow detection on FreeBSD 11.1+ Beginning with FreeBSD 10.4 and 11.1, there is one guard page by default. And the stack autoresizes, so if Rust allocates its own guard page, then FreeBSD's will simply move up one page. The best solution is to just use the OS's guard page.
2021-04-02Rollup merge of #83065 - CDirkx:win-alloc, r=dtolnayDylan DPC-33/+220
Rework `std::sys::windows::alloc` I came across https://github.com/rust-lang/rust/pull/76676#discussion_r488729990, which points out that there was unsound code in the Windows alloc code, creating a &mut to possibly uninitialized memory. I reworked the code so that that particular issue does not occur anymore, and started adding more documentation and safety comments. Full list of changes: - moved and documented the relevant Windows Heap API functions - refactor `allocate_with_flags` to `allocate` (and remove the other helper functions), which now takes just a `bool` if the memory should be zeroed - add checks for if `GetProcessHeap` returned null - add a test that checks if the size and alignment of a `Header` are indeed <= `MIN_ALIGN` - add `#![deny(unsafe_op_in_unsafe_fn)]` and the necessary unsafe blocks with safety comments I feel like I may have overdone the documenting, the unsoundness fix is the most important part; I could spit this PR up in separate parts.
2021-04-02Remove `debug_assert`Christiaan Dirkx-4/+1
2021-04-02Introduce `get_process_heap` and fix atomic ordering.Christiaan Dirkx-13/+22
2021-04-02Rollup merge of #83740 - obi1kenobi:patch-1, r=joshtriplettYuki Okushi-1/+1
Fix comment typo in once.rs I believe I came across a minor typo in a comment. I am not particularly familiar with this part of the codebase, but I have read the surrounding code as well as the referenced `park` and `unpark` functions, and I believe my proposed change is true to the intended meaning of the comment. I intentionally tried to keep the change as minimal as possible. If I have the maintainers' permission, I'd also love to add a comma to improve readability as follows: `Luckily ``park`` comes with the guarantee that if it got an ``unpark`` just before on an unparked thread, it does not park.`