about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2021-06-21Merge `sys_common::bytestring` into `os_str_bytes`Christiaan Dirkx-50/+28
2021-06-21Use `Unsupported` on platforms where `available_concurrency` is not implemented.Christiaan Dirkx-21/+9
2021-06-21Move `available_concurrency` implementation to `sys`Christiaan Dirkx-162/+194
2021-06-20Auto merge of #84967 - CDirkx:os_str_ext, r=m-ou-sebors-78/+92
Move `OsStringExt` and `OsStrExt` to `std::os` Moves the `OsStringExt` and `OsStrExt` traits and implementations from `sys_common` to `os`. `sys_common` is for abstractions over `sys` and shouldn't really contain publicly exported items. This does introduce some duplication: the traits and implementations are now duplicated in `unix`, `wasi`, `hermit`, and `sgx`. However, I would argue that this duplication is no different to how something like `MetadataExt` is duplicated in `linux`, `vxworkx`, `redox`, `solaris` etc. The duplication also matches the fact that the traits on different platforms are technically distinct types: any platform is free to add it's own extra methods to the extension trait.
2021-06-20ErrorKind: Add missing full stopsIan Jackson-3/+3
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-20ErrorKind::FilesystemLoop: Generalise dscriptionIan Jackson-3/+4
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-20Squashed implementation of the passAlex Vlasov-1/+1
2021-06-20Add comment to `std::os::unix::ffi::os_str` explaining that the module is ↵Christiaan Dirkx-0/+3
reused on other platforms.
2021-06-20Make `os_str_bytes::{Buf, Slice}` `pub` and `repr(transparent)`Christiaan Dirkx-8/+4
2021-06-20Move `OsStringExt` and `OsStrExt` to `std::os`Christiaan Dirkx-70/+85
2021-06-20Auto merge of #86463 - fee1-dead:fixed-encode_wide, r=m-ou-sebors-1/+14
Account for self.extra in size_hint for EncodeWide Fixes #86414.
2021-06-19Auto merge of #86034 - nagisa:nagisa/rt-soundness, r=m-ou-sebors-15/+31
Change entry point to 🛡️ against 💥 💥-payloads Guard against panic payloads panicking within entrypoints, where it is UB to do so. Note that there are a number of tradeoffs to consider. For instance, I considered guarding against accidental panics inside the `rt::init` and `rt::cleanup` code as well, as it is not all that obvious these may not panic, but doing so would mean that we initialize certain thread-local slots unconditionally, which has its own problems. Fixes #86030 r? `@m-ou-se`
2021-06-19Remove `Ipv4Addr::is_ietf_protocol_assignment`Christiaan Dirkx-51/+6
2021-06-19Change entry point to 🛡️ against 💥 💥-payloadsSimonas Kazlauskas-15/+31
Guard against panic payloads panicking within entrypoints, where it is UB to do so. Note that there are a number of implementation approaches to consider. Some simpler, some more complicated. This particular solution is nice in that it also guards against accidental implementation issues in various pieces of runtime code, something we cannot prevent statically right now. Fixes #86030
2021-06-19Windows: Fix `Command::env_clear` so it worksChris Denton-0/+6
Previously, it would error unless at least one new environment variable was added.
2021-06-19Auto merge of #86426 - hi-rustin:rustin-patch-lint-warn, r=Aaron1011bors-3/+3
Lint for unused borrows as part of UNUSED_MUST_USE close https://github.com/rust-lang/rust/issues/76264 base on https://github.com/rust-lang/rust/pull/76894 r? `@RalfJung`
2021-06-19Account for self.extra in size_hint for EncodeWideDeadbeef-1/+14
2021-06-18Auto merge of #85815 - YuhanLiin:buf-read-data-left, r=m-ou-sebors-0/+41
Add has_data_left() to BufRead This is a continuation of #40747 and also addresses #40745. The problem with the previous PR was that it had "eof" in its method name. This PR uses a more descriptive method name, but I'm open to changing it.
2021-06-18ErrorKind::NotSeekable: Fix reference to File::open()Ian Jackson-1/+1
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Windows: Fix tidyIan Jackson-2/+1
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Windows: Fix botched rebaseIan Jackson-2/+0
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Provide many more ErrorKinds, motivated by Unix errnosIan Jackson-0/+157
Rationale for the mappings etc. is extensively discussed in the MR https://github.com/rust-lang/rust/pull/79965 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18Windows error codes: Add two missing onesIan Jackson-0/+2
For some reason these aren't in the mingw list. We'll need them shortly. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18Windows error codes: Add very very many from mingwIan Jackson-17/+1846
Dump mingw-64's error codes into our source tree. I have verified with these runes: $ f=library/std/src/sys/windows/c/errors.rs $ diff -ub <(git-cat-file blob HEAD~:$f | sort) <(cat $f | perl -pe 's/WSABASEERR \+ (\d+)/10000 + $1/e' |sort) |grep ^- |less that this does not change any existing values. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18Windows error codes: Move to a separate moduleIan Jackson-49/+56
We're going to add many more of these. This commit is pure code motion, plus the necessary administrivia, as I have veried with the following runes: $ git-diff HEAD~ | grep '^+' |sort >plus $ git-diff HEAD~ | grep '^-' | perl -pe 's/^-/+/' |sort >min $ diff -ub min plus |less The output is precisely the expected `mod` and `use` directives. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18windows errors: Change type name for ERROR_SHARING_VIOLATIONIan Jackson-1/+1
DWORD is a type alias for u32, so this makes no difference. But this entry is anomalous and in my forthcoming commits I am going to import many errors wholesale, and I spotted that my wholesale import didn't match what was here. CC: Chris Denton <christophersdenton@gmail.com> Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Fix a spurious spaceIan Jackson-1/+1
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18Auto merge of #85747 - maxwase:path-symlinks-methods, r=m-ou-sebors-0/+52
Path methods — symlinks improvement This PR adds symlink method for the `Path`. Tracking issue: #85748 For the discussion you can see [internals topic](https://internals.rust-lang.org/t/path-methods-symlinks-improvement/14776) P.S. I'm not fully sure about `stable` attribute, correct me if I'm wrong.
2021-06-18ErrorKind: Reformat the mapping table (windows)Ian Jackson-22/+24
use ErrorKind::*; I don't feel confident enough about Windows things to reorder this alphabetically Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Reformat the mapping table (unix)Ian Jackson-17/+19
* Sort the single matches alphabetically. * use ErrorKind::*; Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18ErrorKind: Reformat the error string tableIan Jackson-21/+22
* Sort alphabetically. * use ErrorKind::*; Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-06-18Add `IpAddr::is_benchmarking`Christiaan Dirkx-3/+36
2021-06-18Add `Ipv6Addr::is_benchmarking`Christiaan Dirkx-29/+67
2021-06-18`no_run` and `ignore` doc attributesMax Wase-2/+4
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-3/+3
2021-06-17Update tracking issueYuhanLiin-1/+1
2021-06-17Rollup merge of #86357 - de-vri-es:simplify-repeated-cfg-ifs, r=m-ou-seMara Bos-100/+10
Rely on libc for correct integer types in os/unix/net/ancillary.rs. This PR is a small maintainability improvement. It simplifies `unix/net/ancillary.rs` in `std` by removing the `cfg_ifs` for casting to the correct integer type, and just rely on libc to define the struct correctly.
2021-06-17Rollup merge of #86202 - a1phyr:spec_io_bytes_size_hint, r=m-ou-seMara Bos-3/+96
Specialize `io::Bytes::size_hint` for more types Improve the result of `<io::Bytes as Iterator>::size_hint` for some readers. I did not manage to specialize `SizeHint` for `io::Cursor` Side question: would it be interesting for `io::Read` to have an optional `size_hint` method ?
2021-06-17Rollup merge of #85925 - clarfonthey:lerp, r=m-ou-seMara Bos-0/+191
Linear interpolation #71016 is a previous attempt at implementation that was closed by the author. I decided to reuse the feature request issue (#71015) as a tracking issue. A member of the rust-lang org will have to edit the original post to be formatted correctly as I am not the issue's original author. The common name `lerp` is used because it is the term used by most code in a wide variety of contexts; it also happens to be the recently chosen name of the function that was added to C++20. To ensure symmetry as a method, this breaks the usual ordering of the method from `lerp(a, b, t)` to `t.lerp(a, b)`. This makes the most sense to me personally, and there will definitely be discussion before stabilisation anyway. Implementing lerp "correctly" is very dififcult even though it's a very common building-block used in all sorts of applications. A good prior reading is [this proposal](http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2018/p0811r2.html#linear-interpolation) for the C++20 lerp which talks about the various guarantees, which I've simplified down to: 1. Exactness: `(0.0).lerp(start, end) == start` and `(1.0).lerp(start, end) == end` 2. Consistency: `anything.lerp(x, x) == x` 3. Monotonicity: once you go up don't go down Fun story: the version provided in that proposal, from what I understand, isn't actually monotonic. I messed around with a *lot* of different lerp implementations because I kind of got a bit obsessed and I ultimately landed on one that uses the fused `mul_add` instruction. Floating-point lerp lore is hard to come by, so, just trust me when I say that this ticks all the boxes. I'm only 90% certain that it's monotonic, but I'm sure that people who care deeply about this will be there to discuss before stabilisation. The main reason for using `mul_add` is that, in general, it ticks more boxes with fewer branches to be "correct." Although it will be slower on architectures without the fused `mul_add`, that's becoming more and more rare and I have a feeling that most people who will find themselves needing `lerp` will also have an efficient `mul_add` instruction available.
2021-06-17Rely on libc for correct integer types in os/unix/net/ancillary.rs.Maarten de Vries-100/+10
2021-06-17Rollup merge of #85802 - Thomasdezeeuw:ioslice-advance, r=m-ou-seYuki Okushi-30/+81
Rename IoSlice(Mut)::advance to advance_slice and add IoSlice(Mut)::advance Also changes the signature of `advance_slice` to accept a `&mut &mut [IoSlice]`, not returning anything. This will better match the `IoSlice::advance` function. Updates https://github.com/rust-lang/rust/issues/62726.
2021-06-17Fix typos in code examples.Mara Bos-2/+2
2021-06-17Document how Windows compares environment variablesChris Denton-3/+22
2021-06-17rename `remaining` to `remaining_slice` and add a new `remaining`Sören Meier-8/+34
2021-06-17Rollup merge of #86141 - amorison:link-ref-in-doc-dyn-keyword, r=kennytmYuki Okushi-2/+5
Link reference in `dyn` keyword documentation The "read more" sentence formatted "object safety" as inline code instead of providing a link to more information. This PR adds a link to the Reference about this matter, as well as the page regarding trait objects. --- We could also put these links in the very first line (instead of the link to the Book) and in the first paragraph which mentions the "object safe" requirement. Personally, I think it's good to keep the link to the Book up-front as it's more accessible than the Reference.
2021-06-16Update tracking issueSören Meier-2/+2
2021-06-16Auto merge of #86179 - the8472:revere-path-cmp, r=kennytmbors-1/+1
optimize Eq implementation for paths Filesystems generally have a tree-ish structure which means paths are more likely to share a prefix than a suffix. Absolute paths are especially prone to share long prefixes. quick benchmark consisting of a search through through a vec containing the absolute paths of all (1850) files in `compiler/`: ``` # old test path::tests::bench_path_cmp ... bench: 227,407 ns/iter (+/- 2,162) # new test path::tests::bench_path_cmp ... bench: 64,976 ns/iter (+/- 1,142) ```
2021-06-16Auto merge of #85820 - CDirkx:is_unicast_site_local, r=joshtriplettbors-52/+1
Remove `Ipv6Addr::is_unicast_site_local` Removes the unstable method `Ipv6Addr::is_unicast_site_local`, see also #85604 where I have tried to summarize related discussion so far. Unicast site-local addresses (`fec0::/10`) were deprecated in [IETF RFC #3879](https://datatracker.ietf.org/doc/html/rfc3879), see also [RFC #4291 Section 2.5.7](https://datatracker.ietf.org/doc/html/rfc4291#section-2.5.7). Any new implementation must no longer support the special behaviour of site-local addresses. This is mentioned in the docs of `is_unicast_site_local` and already implemented in `is_unicast_global`, which considers addresses in `fec0::/10` to have global scope, thus overlapping with `is_unicast_site_local`. Given that RFC #3879 was published in 2004, long before Rust existed, and it is specified that any new implementation must no longer support the special behaviour of site-local addresses, I don't see how a user would ever have a need for `is_unicast_site_local`. It is also confusing that currently both `is_unicast_site_local` and `is_unicast_global` can be `true` for an address, but an address can actually only have a single scope. The deprecating RFC mentions that Site-Local scope was confusing to work with and that the classification of an address as either Link-Local or Global better matches the mental model of users. There has been earlier discussion of removing `is_unicast_site_local` (https://github.com/rust-lang/rust/pull/60145#issuecomment-485970669) which decided against it, but that had the incorrect assumption that the method was already stable; it is not. (This confusion arose from the placement of the unstable attribute on the entire module, instead of on individual methods, resolved in #85672) r? `@joshtriplett` as reviewer of all the related PRs
2021-06-15Document IPv4-mapped and IPv4-compatible addresses.Christiaan Dirkx-14/+72
2021-06-15Rename ErrorKind::Unknown to Uncategorized.Mara Bos-60/+70