about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-01-14remove optimistic spinning from `mpsc::SyncSender`Ibraheem Ahmed-23/+7
2023-01-14Rollup merge of #106799 - scottmcm:remove-unused-generics, r=cuviperYuki Okushi-29/+29
Stop having unused lifetimes on some `impl`s See <https://doc.rust-lang.org/nightly/std/cmp/trait.PartialOrd.html#impl-PartialOrd%3COsStr%3E-for-PathBuf>, where these lifetimes show up even though they're not needed: ![image](https://user-images.githubusercontent.com/18526288/212257802-da275167-38f9-4e2c-aafc-d44f0fc6a7c6.png) With this PR, the unneeded lifetimes are no longer there: ![image](https://user-images.githubusercontent.com/18526288/212257938-0097c4bf-1247-4c91-8445-5bf0dde1b501.png)
2023-01-13Rollup merge of #106701 - ibraheemdev:sync-sender-spin, r=AmanieuMatthias Krüger-33/+49
Fix `mpsc::SyncSender` spinning behavior Resolves https://github.com/rust-lang/rust/issues/106668.
2023-01-12Stop having unused lifetimes on some `impl`sScott McMurray-29/+29
2023-01-13Rollup merge of #106446 - bzEq:fix-unwind-lsda, r=AmanieuYuki Okushi-9/+22
[LSDA] Take ttype_index into account when taking unwind action If `cs_action != 0`, we should check the `ttype_index` field in action record. If `ttype_index == 0`, a clean up action is taken; otherwise catch action is taken. This can fix unwind failure on AIX which uses LLVM's libunwind by default. IIUC, rust's LSDA is borrowed from c++ and I'm assuming itanium-cxx-abi https://itanium-cxx-abi.github.io/cxx-abi/exceptions.pdf should be followed, so the fix follows what libcxxabi does. See https://github.com/llvm/llvm-project/blob/ec48682ce9f61d056361c5095f21e930b8365661/libcxxabi/src/cxa_personality.cpp#L152 for use of `ttype_index`.
2023-01-12Avoid __cxa_thread_atexit_impl on EmscriptenIngvar Stepanyan-8/+2
- Fixes https://github.com/rust-lang/rust/issues/91628. - Fixes https://github.com/emscripten-core/emscripten/issues/15722. See discussion in both issues. The TL;DR is that weak linkage causes LLVM to produce broken Wasm, presumably due to pointer mismatch. The code is casting a void pointer to a function pointer with specific signature, but Wasm is very strict about function pointer compatibility, so the resulting code is invalid. Ideally LLVM should catch this earlier in the process rather than emit invalid Wasm, but it currently doesn't and this is an easy and valid fix, given that Emcripten doesn't have `__cxa_thread_atexit_impl` these days anyway. Unfortunately, I can't add a regression test as even after looking into this issue for a long time, I couldn't reproduce it with any minimal Rust example, only with extracted LLVM IR or on a large project involving Rust + C++. r? @alexcrichton
2023-01-12Rollup merge of #106638 - RalfJung:realstd, r=thomccMatthias Krüger-7/+15
std tests: use __OsLocalKeyInner from realstd This is basically the same as https://github.com/rust-lang/rust/pull/100201, but for __OsLocalKeyInner: Some std tests are failing in Miri on Windows because [this static](https://github.com/rust-lang/rust/blob/a377893da2cd7124e5a18c7116cbb70e16dd5541/library/std/src/sys/windows/thread_local_key.rs#L234-L239) is getting duplicated, and Miri does not handle that properly -- Miri does not support this magic `.CRT$XLB` linker section, but instead just looks up this particular hard-coded static in the standard library. This PR lets the test suite use the std static instead of having its own copy. Fixes https://github.com/rust-lang/miri/issues/2754 r? `@thomcc`
2023-01-11rework and document backoff behavior of `sync::mpsc`Ibraheem Ahmed-31/+30
2023-01-11Stop probing for statx unless necessaryMateusz Guzik-27/+41
As is the current toy program: fn main() -> std::io::Result<()> { use std::fs; let metadata = fs::metadata("foo.txt")?; assert!(!metadata.is_dir()); Ok(()) } ... observed under strace will issue: [snip] statx(0, NULL, AT_STATX_SYNC_AS_STAT, STATX_ALL, NULL) = -1 EFAULT (Bad address) statx(AT_FDCWD, "foo.txt", AT_STATX_SYNC_AS_STAT, STATX_ALL, {stx_mask=STATX_ALL|STATX_MNT_ID, stx_attributes=0, stx_mode=S_IFREG|0644, stx_size=0, ...}) = 0 While statx is not necessarily always present, checking for it can be delayed to the first error condition. Said condition may very well never happen, in which case the check got avoided altogether. Note this is still suboptimal as there still will be programs issuing it, but bulk of the problem is removed. Tested by forbidding the syscall for the binary and observing it correctly falls back to newfstatat. While here tidy up the commentary, in particular by denoting some problems with the current approach.
2023-01-11Rollup merge of #106664 - chenyukang:yukang/fix-106597-remove-lseek, r=cuvipernils-4/+6
Remove unnecessary lseek syscall when using std::fs::read Fixes #106597 r? ```@bjorn3```
2023-01-11Change `src/test` to `tests` in source files, fix tidy and testsAlbert Larsan-1/+1
2023-01-10add `SyncSender::send_timeout` testIbraheem Ahmed-1/+18
2023-01-10fix `SyncSender` spinning behaviorIbraheem Ahmed-1/+1
2023-01-11use with_capacity in read read_to_stringyukang-4/+2
2023-01-09std tests: use __OsLocalKeyInner from realstdRalf Jung-7/+15
2023-01-09Add commentKai Luo-1/+3
2023-01-09Move to intepret_cs_actionKai Luo-24/+17
2023-01-09Add commentsKai Luo-0/+2
2023-01-09std test: better type name, clarifying commentRalf Jung-12/+12
2023-01-09Also check ttype_index when using SJLJKai Luo-2/+10
2023-01-09Disable `linux_ext` in wasm32 and fortanix rustdoc builds.John Millikin-0/+9
The `std::os::unix` module is stubbed out when building docs for these target platforms. The introduction of Linux-specific extension traits caused `std::os::net` to depend on sub-modules of `std::os::unix`, which broke rustdoc for the `wasm32-unknown-unknown` target. Adding an additional `#[cfg]` guard solves that rustdoc failure by not declaring `linux_ext` on targets with a stubbed `std::os::unix`.
2023-01-08Change memory ordering in System wrapper exampleMikail Bagishov-4/+4
Currently, the `SeqCst` ordering is used, which seems unnecessary: + Even `Relaxed` ordering guarantees that all updates are atomic and are executed in total order + User code only reads atomic for monitoring purposes, no "happens-before" relationships with actual allocations and deallocations are needed for this If argumentation above is correct, I propose changing ordering to `Relaxed` to clarify that no synchronization is required here, and improve performance (if somebody copy-pastes this example into their code).
2023-01-08Rollup merge of #103104 - SUPERCILEX:sep-ref, r=dtolnayYuki Okushi-1/+1
Stabilize `main_separator_str` See reasoning here: https://github.com/rust-lang/rust/issues/94071#issuecomment-1279872605. Closes #94071.
2023-01-08Auto merge of #104658 - thomcc:rand-update-and-usable-no_std, r=Mark-Simulacrumbors-10/+39
Update `rand` in the stdlib tests, and remove the `getrandom` feature from it. The main goal is actually removing `getrandom`, so that eventually we can allow running the stdlib test suite on tier3 targets which don't have `getrandom` support. Currently those targets can only run the subset of stdlib tests that exist in uitests, and (generally speaking), we prefer not to test libstd functionality in uitests, which came up recently in https://github.com/rust-lang/rust/pull/104095 and https://github.com/rust-lang/rust/pull/104185. Additionally, the fact that we can't update `rand`/`getrandom` means we're stuck with the old set of tier3 targets, so can't test new ones. ~~Anyway, I haven't checked that this actually does allow use on tier3 targets (I think it does not, as some work is needed in stdlib submodules) but it moves us slightly closer to this, and seems to allow at least finally updating our `rand` dep, which definitely improves the status quo.~~ Checked and works now. For the most part, our tests and benchmarks are fine using hard-coded seeds. A couple tests seem to fail with this (stuff manipulating the environment expecting no collisions, for example), or become pointless (all inputs to a function become equivalent). In these cases I've done a (gross) dance (ab)using `RandomState` and `Location::caller()` for some extra "entropy". Trying to share that code seems *way* more painful than it's worth given that the duplication is a 7-line function, even if the lines are quite gross. (Keeping in mind that sharing it would require adding `rand` as a non-dev dep to std, and exposing a type from it publicly, all of which sounds truly awful, even if done behind a perma-unstable feature). See also some previous attempts: - https://github.com/rust-lang/rust/pull/86963 (in particular https://github.com/rust-lang/rust/pull/86963#issuecomment-885438936 which explains why this is non-trivial) - https://github.com/rust-lang/rust/pull/89131 - https://github.com/rust-lang/rust/pull/96626#issuecomment-1114562857 (I tried in that PR at the same time, but settled for just removing the usage of `thread_rng()` from the benchmarks, since that was the main goal). - https://github.com/rust-lang/rust/pull/104185 - Probably more. It's very tempting of a thing to "just update". r? `@Mark-Simulacrum`
2023-01-08Remove unnecessary lseek syscall when using std::fs::readyukang-2/+6
2023-01-07docs: make `HashSet::retain` doctest more clearEzra Shaw-1/+1
2023-01-04Update rand in the stdlib tests, and remove the getrandom feature from itThom Chiovoloni-10/+39
2023-01-04docs: fix broken link "search bar"Michael Howell-1/+1
2023-01-04[LSDA] Take ttype_index into account when taking actionKai Luo-2/+10
If cs_action != 0, we should check the ttype_index field in action record. If ttype_index == 0, a clean up action is taken.
2023-01-04Rollup merge of #106327 - gimbles:dbg, r=jyn514Matthias Krüger-0/+1
Add tidy check for dbg Fixes #106169
2023-01-04relax reference requirement on from_abstract_namemllken-2/+2
2023-01-03Rollup merge of #106045 - RalfJung:oom-nounwind-panic, r=AmanieuMichael Goulet-1/+1
default OOM handler: use non-unwinding panic, to match std handler The OOM handler in std will by default abort. This adjusts the default in liballoc to do the same, using the `can_unwind` flag on the panic info to indicate a non-unwinding panic. In practice this probably makes little difference since the liballoc default will only come into play in no-std situations where people write a custom panic handler, which most likely will not implement unwinding. But still, this seems more consistent. Cc `@rust-lang/wg-allocators,` https://github.com/rust-lang/rust/issues/66741
2023-01-03Make ExitStatus an inhabited type on all platformsIan Jackson-18/+19
Even where actually running processes is not supported. Needed for the next commit. The manual trait implementations now belong on ExitStatusError, which still can't exist.
2023-01-02Rollup merge of #104298 - tbu-:pr_set_extension_caveats, r=m-ou-seMichael Goulet-3/+30
Add notes and examples about non-intuitive `PathBuf::set_extension` behavior Basically, passing the empty string will actually remove the extension instead of setting it to the empty string. This might change what is considered to be an extension. Additionally, passing an extension that contains dots will make the path only consider the last part of it to be the new extension.
2023-01-02default OOM handler: use non-unwinding panic (unless -Zoom=panic is set), to ↵Ralf Jung-1/+1
match std handler
2023-01-01improve wording of `thread::park` docsIbraheem Ahmed-4/+3
2023-01-01Document a way to limit read_line lengthKornel-2/+3
2023-01-01Document read_line gotchaKornel-2/+5
2022-12-31Rollup merge of #106280 - Ezrashaw:path-join-docs-better, r=thomccMatthias Krüger-0/+3
docs: add link to `Path::join` in `PathBuf::push` Fixes #106219 Hopefully my wording is alright.
2022-12-31Add tidy check for dbggimbles-0/+1
2022-12-31std: use id-based thread parking on SOLIDjoboet-179/+40
2022-12-30Rollup merge of #105903 - joboet:unify_parking, r=m-ou-seMichael Goulet-240/+207
Unify id-based thread parking implementations Multiple platforms currently use thread-id-based parking implementations (NetBSD and SGX[^1]). Even though the strategy does not differ, these are duplicated for each platform, as the id is encoded into an atomic thread variable in different ways for each platform. Since `park` is only called by one thread, it is possible to move the thread id into a separate field. By ensuring that the field is only written to once, before any other threads access it, these accesses can be unsynchronized, removing any restrictions on the size and niches of the thread id. This PR also renames the internal `thread_parker` modules to `thread_parking`, as that name now better reflects their contents. I hope this does not add too much reviewing noise. r? `@m-ou-se` `@rustbot` label +T-libs [^1]: SOLID supports this as well, I will switch it over in a follow-up PR.
2022-12-31Add notes and examples about non-intuitive `PathBuf::set_extension` behaviorTobias Bucher-3/+30
Basically, passing the empty string will actually remove the extension instead of setting it to the empty string. This might change what is considered to be an extension. Additionally, passing an extension that contains dots will make the path only consider the last part of it to be the new extension.
2022-12-30Auto merge of #105651 - tgross35:once-cell-inline, r=m-ou-sebors-1/+21
Add #[inline] markers to once_cell methods Added inline markers to all simple methods under the `once_cell` feature. Relates to #74465 and #105587 This should not block #105587
2022-12-30Auto merge of #106296 - matthiaskrgr:rollup-ukdbqwx, r=matthiaskrgrbors-29/+37
Rollup of 4 pull requests Successful merges: - #99244 (doc: clearer and more correct Iterator::scan) - #103707 (Replace libstd, libcore, liballoc terminology in docs) - #104182 (`IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation.) - #106273 (rustdoc: remove redundant CSS `.source .content { overflow: visible }`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2022-12-30Rollup merge of #104182 - gabhijit:ipv6-in6addr-any-doc-fix, r=m-ou-seMatthias Krüger-0/+9
`IN6ADDR_ANY_INIT` and `IN6ADDR_LOOPBACK_INIT` documentation. Added documentation for IPv6 Addresses `IN6ADDR_ANY_INIT` also known as `in6addr_any` and `IN6ADDR_LOOPBACK_INIT` also known as `in6addr_loopback` similar to `INADDR_ANY` for IPv4 Addresses.
2022-12-30std: remove unnecessary `#[cfg]` on NetBSDjoboet-2/+0
2022-12-30std: rename `Parker::new` to `Parker::new_in_place`, add safe `Parker::new` ↵joboet-24/+16
constructor for SGX
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-16/+16
2022-12-30Replace libstd, libcore, liballoc in docs.jonathanCogan-13/+12