about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2021-06-22Auto merge of #86527 - JohnTitor:rollup-cbu78g4, r=JohnTitorbors-177/+277
Rollup of 11 pull requests Successful merges: - #85054 (Revert SGX inline asm syntax) - #85182 (Move `available_concurrency` implementation to `sys`) - #86037 (Add `io::Cursor::{remaining, remaining_slice, is_empty}`) - #86114 (Reopen #79692 (Format symbols under shared frames)) - #86297 (Allow to pass arguments to rustdoc-gui tool) - #86334 (Resolve type aliases to the type they point to in intra-doc links) - #86367 (Fix comment about rustc_inherit_overflow_checks in abs().) - #86381 (Add regression test for issue #39161) - #86387 (Remove `#[allow(unused_lifetimes)]` which is now unnecessary) - #86398 (Add regression test for issue #54685) - #86493 (Say "this enum variant takes"/"this struct takes" instead of "this function takes") Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-06-22Rollup merge of #86114 - JDuchniewicz:feat/panic-frame-fmt, r=yaahcYuki Okushi-3/+2
Reopen #79692 (Format symbols under shared frames) Reopening #79692.
2021-06-22Rollup merge of #86037 - soerenmeier:cursor_remaining, r=yaahcYuki Okushi-4/+85
Add `io::Cursor::{remaining, remaining_slice, is_empty}` Tracking issue: #86369 I came across an inconvenience when answering the following [Stack Overflow](https://stackoverflow.com/questions/67831170) question. To get the remaining slice you have to call `buff.fill_buf().unwrap()`. Which in my opinion doesn't really tell you what is returned (in the context of Cursor). To improve readability and convenience when using Cursor i propose adding the method `remaining`. The next thing i found inconvenient (unnecessary long) was detecting if the cursor reached the end. There are a few ways this can be achieved right now: - `buff.fill_buf().unwrap().is_empty()` - `buff.position() >= buff.get_ref().len()` - `buff.bytes().next().is_none()` Which all seem a bit unintuitive, hidden in trait documentations or just a bit long for such a simple task. Therefor i propose another method called `is_empty`, maybe with another name, since this one may leave room for interpretation on what really is empty (the underlying slice, the remaining slice or maybe the position). Since it seemed easier to create this PR instead of an RFC i did that, if an RFC is wanted, i can close this PR and write an RFC first.
2021-06-22Rollup merge of #85182 - CDirkx:available_concurrency, r=JohnTitorYuki Okushi-162/+182
Move `available_concurrency` implementation to `sys` This splits out the platform-specific implementation of `available_concurrency` to the corresponding platforms under `sys`. No changes are made to the implementation. Tidy didn't lint against this code being originally added outside of `sys` because of a bug (see #84677), this PR also reverts the exclusion that was introduced in that bugfix. Tracking issue of `available_concurrency`: #74479
2021-06-22Rollup merge of #85054 - jethrogb:jb/sgx-inline-asm, r=AmanieuYuki Okushi-8/+8
Revert SGX inline asm syntax This was erroneously changed in #83387
2021-06-21Auto merge of #86383 - shamatar:slice_len_lowering, r=bjorn3bors-1/+1
Add MIR pass to lower call to `core::slice::len` into `Len` operand During some larger experiment with range analysis I've found that code like `let l = slice.len()` produces different MIR then one found in bound checks. This optimization pass replaces terminators that are calls to `core::slice::len` with just a MIR operand and Goto terminator. It uses some heuristics to remove the outer borrow that is made to call `core::slice::len`, but I assume it can be eliminated, just didn't find how. Would like to express my gratitude to `@oli-obk` who helped me a lot on Zullip
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