about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2021-11-19Remove unnecessary doc linksMaybe Waffle-2/+0
2021-11-19Rollup merge of #90942 - JohnTitor:should-os-error-3, r=m-ou-seYuki Okushi-4/+7
windows: Return the "Not Found" error when a path is empty Fixes #90940
2021-11-18Auto merge of #90774 - alexcrichton:tweak-const, r=m-ou-sebors-6/+6
std: Tweak expansion of thread-local const This commit tweaks the expansion of `thread_local!` when combined with a `const { ... }` value to help ensure that the rules which apply to `const { ... }` blocks will be the same as when they're stabilized. Previously with this invocation: thread_local!(static NAME: Type = const { init_expr }); this would generate (on supporting platforms): #[thread_local] static NAME: Type = init_expr; instead the macro now expands to: const INIT_EXPR: Type = init_expr; #[thread_local] static NAME: Type = INIT_EXPR; with the hope that because `init_expr` is defined as a `const` item then it's not accidentally allowing more behavior than if it were put into a `static`. For example on the stabilization issue [this example][ex] now gives the same error both ways. [ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-18Auto merge of #90382 - alexcrichton:wasm64-libstd, r=joshtriplettbors-14/+15
std: Get the standard library compiling for wasm64 This commit goes through and updates various `#[cfg]` as appropriate to get the wasm64-unknown-unknown target behaving similarly to the wasm32-unknown-unknown target. Most of this is just updating various conditions for `target_arch = "wasm32"` to also account for `target_arch = "wasm64"` where appropriate. This commit also lists `wasm64` as an allow-listed architecture to not have the `restricted_std` feature enabled, enabling experimentation with `-Z build-std` externally. The main goal of this commit is to enable playing around with `wasm64-unknown-unknown` externally via `-Z build-std` in a way that's similar to the `wasm32-unknown-unknown` target. These targets are effectively the same and only differ in their pointer size, but wasm64 is much newer and has much less ecosystem/library support so it'll still take time to get wasm64 fully-fledged.
2021-11-17windows: Return the "Not Found" error when a path is emptyYuki Okushi-4/+7
2021-11-16Rollup merge of #90835 - sunfishcode:sunfishcode/wasi-char-device, ↵Yuki Okushi-2/+6
r=alexcrichton Rename WASI's `is_character_device` to `is_char_device`. Rename WASI's `FileTypeExt::is_character_device` to `FileTypeExt::is_char_device`, for consistency with the Unix `FileTypeExt::is_char_device`. Also, add a `FileTypeExt::is_socket` function, for consistency with the Unix `FileTypeExt::is_socket` function. r? `@alexcrichton`
2021-11-16Rollup merge of #90790 - tamaroning:fix-lib-std-test, r=Mark-SimulacrumYuki Okushi-12/+3
Fix standard library test with read_link closes #90669 resolve this issue by comparing between Paths instead of strs
2021-11-16Rollup merge of #88601 - ibraheemdev:termination-result-infallible, r=yaahcYuki Okushi-0/+9
Implement `Termination` for `Result<Infallible, E>` As noted in #43301, `Result<!, E>` is not usable on stable.
2021-11-16Rollup merge of #85766 - workingjubilee:file-options, r=yaahcYuki Okushi-5/+4
Stabilize File::options() Renames File::with_options to File::options, per consensus in rust-lang/rust#65439, and stabilizes it.
2021-11-14Auto merge of #90596 - the8472:path-hash-opt, r=Mark-Simulacrumbors-11/+140
Optimize Eq and Hash for Path/PathBuf ``` # new test path::tests::bench_hash_path_long ... bench: 86 ns/iter (+/- 1) test path::tests::bench_hash_path_short ... bench: 13 ns/iter (+/- 1) test path::tests::bench_path_hashset ... bench: 197 ns/iter (+/- 6) test path::tests::bench_path_hashset_miss ... bench: 94 ns/iter (+/- 4) # old test path::tests::bench_hash_path_long ... bench: 192 ns/iter (+/- 2) test path::tests::bench_hash_path_short ... bench: 33 ns/iter (+/- 1) test path::tests::bench_path_hashset ... bench: 1,121 ns/iter (+/- 24) test path::tests::bench_path_hashset_miss ... bench: 273 ns/iter (+/- 6) ```
2021-11-13Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obkbors-1/+2
Stabilize `const_raw_ptr_deref` for `*const T` This stabilizes dereferencing immutable raw pointers in const contexts. It does not stabilize `*mut T` dereferencing. This is behind the same feature gate as mutable references. closes https://github.com/rust-lang/rust/issues/51911
2021-11-13Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrumbors-0/+4
pub use core::simd; A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use. `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available. `core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts. There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out. The major types are - `core::simd::Simd<T, N>` - `core::simd::Mask<T, N>` There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.
2021-11-12Expose portable-simd as core::simdJubilee Young-0/+4
This enables programmers to use a safe alternative to the current `extern "platform-intrinsics"` API for writing portable SIMD code. This is `#![feature(portable_simd)]` as tracked in #86656
2021-11-12Refactor weak symbols in std::sys::unixJosh Stone-191/+134
This makes a few changes to the weak symbol macros in `sys::unix`: - `dlsym!` is added to keep the functionality for runtime `dlsym` lookups, like for `__pthread_get_minstack@GLIBC_PRIVATE` that we don't want to show up in ELF symbol tables. - `weak!` now uses `#[linkage = "extern_weak"]` symbols, so its runtime behavior is just a simple null check. This is also used by `syscall!`. - On non-ELF targets (macos/ios) where that linkage is not known to behave, `weak!` is just an alias to `dlsym!` for the old behavior. - `raw_syscall!` is added to always call `libc::syscall` on linux and android, for cases like `clone3` that have no known libc wrapper. The new `weak!` linkage does mean that you'll get versioned symbols if you build with a newer glibc, like `WEAK DEFAULT UND statx@GLIBC_2.28`. This might seem problematic, but old non-weak symbols can tie the build to new versions too, like `dlsym@GLIBC_2.34` from their recent library unification. If you build with an old glibc like `dist-x86_64-linux` does, you'll still get unversioned `WEAK DEFAULT UND statx`, which may be resolved based on the runtime glibc. I also found a few functions that don't need to be weak anymore: - Android can directly use `ftruncate64`, `pread64`, and `pwrite64`, as these were added in API 12, and our baseline is API 14. - Linux can directly use `splice`, added way back in glibc 2.5 and similarly old musl. Android only added it in API 21 though.
2021-11-12Rollup merge of #90704 - ijackson:exitstatus-comments, r=joshtriplettMatthias Krüger-1/+9
Unix ExitStatus comments and a tiny docs fix Some nits left over from #88300
2021-11-12Rename WASI's `is_character_device` to `is_char_device`.Dan Gohman-2/+6
Rename WASI's `FileTypeExt::is_character_device` to `FileTypeExt::is_char_device`, for consistency with the Unix `FileTypeExt::is_char_device`. Also, add a `FileTypeExt::is_socket` function, for consistency with the Unix `FileTypeExt::is_socket` function.
2021-11-11`Prefix` can be case-insensitive, delegate to its Hash impl instead of ↵The8472-0/+9
trying to hash the raw bytes This should have 0 performance overhead on unix since Prefix is always None.
2021-11-11process::ExitStatus: Discuss `exit` vs `_exit` in a comment.Ian Jackson-0/+5
As discussed here https://github.com/rust-lang/rust/pull/88300#issuecomment-936097710 I felt this was the best place to put this (rather than next to ExitStatusExt). After all, it's a property of the ExitStatus type on Unix. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11unix::ExitStatus: Add comment saying that it's a wait statusIan Jackson-0/+3
With cross-reference. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11unix::ExitStatusExt: Correct reference to _exit system callIan Jackson-1/+1
As discussed here https://github.com/rust-lang/rust/pull/88300#issuecomment-936085371 exit is (conventionally) a library function, with _exit being the actual system call. I have checked the other references and they say "if the process terminated by calling `exti`". I think despite the slight imprecision (strictly, it should read iff ... `_exit`), this is clearer. Anyone who knows about the distinction between `exit` and `_exit` will not be confused. `_exit` is the correct traditional name for the system call, despite Linux calling it `exit_group` or `exit`: https://www.freebsd.org/cgi/man.cgi?query=_exit&sektion=2&n=1 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-11-11Auto merge of #88798 - sunfishcode:sunfishcode/windows-null-handles, ↵bors-50/+85
r=joshtriplett Fix assertion failures in `OwnedHandle` with `windows_subsystem`. As discussed in #88576, raw handle values in Windows can be null, such as in `windows_subsystem` mode, or when consoles are detached from a process. So, don't use `NonNull` to hold them, don't assert that they're not null, and remove `OwnedHandle`'s `repr(transparent)`. Introduce a new `HandleOrNull` type, similar to `HandleOrInvalid`, to cover the FFI use case. r? `@joshtriplett`
2021-11-11compare between Path instead of strtamaron-12/+3
2021-11-10Auto merge of #90784 - matthiaskrgr:rollup-car8g12, r=matthiaskrgrbors-9/+10
Rollup of 3 pull requests Successful merges: - #89930 (Only use `clone3` when needed for pidfd) - #90736 (adjust documented inline-asm register constraints) - #90783 (Update Miri) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-11-10Rollup merge of #89930 - cuviper:avoid-clone3, r=joshtriplettMatthias Krüger-9/+10
Only use `clone3` when needed for pidfd In #89522 we learned that `clone3` is interacting poorly with Gentoo's `sandbox` tool. We only need that for the unstable pidfd extensions, so otherwise avoid that and use a normal `fork`. This is a re-application of beta #89924, now that we're aware that we need more than just a temporary release fix. I also reverted 12fbabd27f700, as that was just fallout from using `clone3` instead of `fork`. r? `@Mark-Simulacrum` cc `@joshtriplett`
2021-11-10std: Tweak expansion of thread-local constAlex Crichton-6/+6
This commit tweaks the expansion of `thread_local!` when combined with a `const { ... }` value to help ensure that the rules which apply to `const { ... }` blocks will be the same as when they're stabilized. Previously with this invocation: thread_local!(static NAME: Type = const { init_expr }); this would generate (on supporting platforms): #[thread_local] static NAME: Type = init_expr; instead the macro now expands to: const INIT_EXPR: Type = init_expr; #[thread_local] static NAME: Type = INIT_EXPR; with the hope that because `init_expr` is defined as a `const` item then it's not accidentally allowing more behavior than if it were put into a `static`. For example on the stabilization issue [this example][ex] now gives the same error both ways. [ex]: https://github.com/rust-lang/rust/issues/84223#issuecomment-953384298
2021-11-10Review commentsAlex Crichton-2/+2
2021-11-10Use `target_family = "wasm"`Alex Crichton-20/+10
2021-11-10std: Get the standard library compiling for wasm64Alex Crichton-13/+24
This commit goes through and updates various `#[cfg]` as appropriate to get the wasm64-unknown-unknown target behaving similarly to the wasm32-unknown-unknown target. Most of this is just updating various conditions for `target_arch = "wasm32"` to also account for `target_arch = "wasm64"` where appropriate. This commit also lists `wasm64` as an allow-listed architecture to not have the `restricted_std` feature enabled, enabling experimentation with `-Z build-std` externally. The main goal of this commit is to enable playing around with `wasm64-unknown-unknown` externally via `-Z build-std` in a way that's similar to the `wasm32-unknown-unknown` target. These targets are effectively the same and only differ in their pointer size, but wasm64 is much newer and has much less ecosystem/library support so it'll still take time to get wasm64 fully-fledged.
2021-11-10Fix collection entry API documentation.Joseph Roitman-1/+1
2021-11-10Rollup merge of #90751 - ehuss:update-books, r=ehussMatthias Krüger-1/+1
Update books ## nomicon 1 commits in 358e6a61d5f4f0496d0a81e70cdcd25d05307342..c6b4bf831e9a40aec34f53067d20634839a6778b 2021-10-20 11:23:12 -0700 to 2021-11-09 02:30:56 +0900 - Replace some use of variant with covariant (rust-lang/nomicon#322) ## book 11 commits in fd9299792852c9a368cb236748781852f75cdac6..5c5dbc5b196c9564422b3193264f3288d2a051ce 2021-10-22 21:59:46 -0400 to 2021-11-09 19:30:43 -0500 - Fix constants link. - Fix updated anchor - Propagate edits to chapter 2 back - Edits to nostarch's chapter 3 edits - ch 3 from nostarch - Fix Cargo.toml snippet about custom derive macros - Snapshot of chapter 9 for nostarch - Create tmp/src for converting quotes, not sure why this broke but ok - Update question mark to better explain where it can be used - Clarify sentence about Results in functions that don't return Result. Fixes rust-lang/book#2912. - Merge pull request rust-lang/book#2913 from covariant/patch-1 ## rust-by-example 2 commits in 27f1ff5e440ef78828b68ab882b98e1b10d9af32..e9d45342d7a6c1def4731f1782d87ea317ba30c3 2021-10-13 08:04:40 -0300 to 2021-11-02 13:33:03 -0500 - Enums: Linked-List Needs Re-Wording (rust-lang/rust-by-example#1469) - fix: Use the point as top left corner for `square` (rust-lang/rust-by-example#1471) ## rustc-dev-guide 13 commits in b06008731af0f7d07cd0614e820c8276dfed1c18..196ef69aa68f2cef44f37566ee7db37daf00301b 2021-10-21 15:13:09 -0500 to 2021-11-07 07:48:47 -0600 - Fix typo: [upv.rs_mentioned] -&gt; [upvars_mentioned] - Add note to emphasize replacing TARGET_TRIPLE (rust-lang/rustc-dev-guide#1250) - Remove some legacy test suites. - tiny capitalization fix - Fix date - Update some date-check comments - Ensure date-check cron job is using latest stable Rust - enhance subtree docs, link to clippy docs - Edit introduction to bootstrapping - Some minor adjustments to the diagnostic documentation - Edit "About this guide" for semantic line feeds - Fix `rustc_mir` related links (rust-lang/rustc-dev-guide#1228) - Add documentation for LLVM CFI support ## edition-guide 3 commits in 7c0088ca744d293a5f4b1e2ac378e7c23d30fe55..27f4a84d3852e9416cae5861254fa53a825c56bd 2021-10-05 13:28:05 +0200 to 2021-11-08 10:13:20 -0500 - Add a missing period (rust-lang/edition-guide#271) - Fix syntax error in code example (rust-lang/edition-guide#270) - Fixed an example error of prelude.md (rust-lang/edition-guide#269)
2021-11-10Rollup merge of #90748 - cuviper:track-setgroups, r=dtolnayMatthias Krüger-1/+1
Add a real tracking issue for `CommandExt::groups` The `unstable` attribute referenced the closed RFE #38527, so I filed tracking issue #90747.
2021-11-09Update booksEric Huss-1/+1
2021-11-09Add a real tracking issue for `CommandExt::groups`Josh Stone-1/+1
2021-11-09remove redundant .iter() call since zip() takes an IntoIterator argumentThe8472-6/+5
2021-11-09add fast path on Path::eq for exact equalityThe8472-1/+20
2021-11-09optimize Hash for PathThe8472-2/+28
Hashing does not have to use the whole Components parsing machinery because we only need it to match the normalizations that Components does. * stripping redundant separators -> skipping separators * stripping redundant '.' directories -> skipping '.' following after a separator That's all it takes. And instead of hashing individual slices for each component we feed the bytes directly into the hasher which avoids hashing the length of each component in addition to its contents.
2021-11-09add benchmarks and tests for Hash and Eq impls on PathThe8472-2/+78
The tests check for consistency between Ord, Eq and Hash
2021-11-09Stabilize File::options()Jubilee Young-5/+4
Renames File::with_options to File::options, per consensus in rust-lang/rust#65439, and stabilizes it.
2021-11-08kmc-solid: Avoid the use of `asm_const`Tomoaki Kawada-7/+6
2021-11-07Auto merge of #89310 - joshtriplett:available-concurrency-affinity, r=m-ou-sebors-0/+8
Make `std::thread::available_concurrency` support process-limited number of CPUs Use `libc::sched_getaffinity` and count the number of CPUs in the returned mask. This handles cases where the process doesn't have access to all CPUs, such as when limited via `taskset` or similar. This also covers cgroup cpusets.
2021-11-06Stabilize `const_raw_ptr_deref` for `*const T`Jacob Pratt-1/+2
This stabilizes dereferencing immutable raw pointers in const contexts. It does not stabilize `*mut T` dereferencing. This is placed behind the `const_raw_mut_ptr_deref` feature gate.
2021-11-06use matches!() macro in more placesMatthias Krüger-7/+2
2021-11-05Also note tool expectations of fork vs clone3Josh Stone-0/+2
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-11-05Update another comment on fork vs. clone3Josh Stone-2/+2
2021-11-05Only use `clone3` when needed for pidfdJosh Stone-7/+6
In #89522 we learned that `clone3` is interacting poorly with Gentoo's `sandbox` tool. We only need that for the unstable pidfd extensions, so otherwise avoid that and use a normal `fork`.
2021-11-05Add UnwindSafe to OnceMilo-0/+4
2021-11-04Auto merge of #90392 - solid-rs:fix-solid-support, r=Mark-Simulacrumbors-1/+1
kmc-solid: Fix SOLID target This PR is a follow-up for #86191 and necessary to make the [`*-kmc-solid_*`](https://doc.rust-lang.org/nightly/rustc/platform-support/kmc-solid.html) Tier 3 targets actually usable. - Bumps `libc` to 0.2.106, which includes <https://github.com/rust-lang/libc/pull/2227>. - Applies the change made by #89324 to this target's target-specific code.
2021-11-02formattingDrMeepster-1/+1
2021-11-02fix change clobbered by rebaseDrMeepster-7/+23
2021-11-02implement review suggestionsDrMeepster-9/+31