about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2021-05-12unix: impl ExitStatusExt for ExitStatusErrorIan Jackson-10/+76
It is unergnomic to have to say things like bad.into_status().signal() Implementing `ExitStatusExt` for `ExitStatusError` fixes this. Unfortunately it does mean making a previously-infallible method capable of panicing, although of course the existing impl remains infallible. The alternative would be a whole new `ExitStatusErrorExt` trait. `<ExitStatus as ExitStatusExt>::into_raw()` is not particularly ergonomic to call because of the often-required type annotation. See for example the code in the test case in library/std/src/sys/unix/process/process_unix/tests.rs Perhaps we should provide equivalent free functions for `ExitStatus` and `ExitStatusExt` in std::os::unix::process and maybe deprecate this trait method. But I think that is for the future. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12Provide ExitStatusErrorIan Jackson-13/+227
Closes #73125 This is in pursuance of Issue #73127 Consider adding #[must_use] to std::process::ExitStatus In MR #81452 Add #[must_use] to [...] process::ExitStatus we concluded that the existing arrangements in are too awkward so adding that #[must_use] is blocked on improving the ergonomics. I wrote a mini-RFC-style discusion of the approach in https://github.com/rust-lang/rust/issues/73125#issuecomment-771092741 Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-11Fix typo in commentAndrew Halle-1/+1
missing space in "rootseparator"
2021-05-12Rollup merge of #85136 - shirshak55:master, r=dtolnayYuki Okushi-10/+10
Change param name (k to key and v to value) in std::env module 1. When I was reading code the ide displayed `k` and `v`, so I thought it would be better to show key and value? 2. I noticed var method already uses `key` instead of `k` so it is more consistent to use `key` instead of `k`? Thanks
2021-05-11use the correct attributes and add helper functionRoxane-2/+2
2021-05-11Override `clone_from` for some typesBenoît du Garreau-1/+18
2021-05-11Auto merge of #85109 - RalfJung:remove-const_fn, r=oli-obkbors-1/+0
remove const_fn feature gate Fixes https://github.com/rust-lang/rust/issues/84510 r? `@oli-obk`
2021-05-11Auto merge of #80300 - LeSeulArtichaut:80275-doc-inline, r=Manishearthbors-1/+0
Emit errors/warns on some wrong uses of rustdoc attributes This PR adds a few diagnostics: - error if conflicting `#[doc(inline)]`/`#[doc(no_inline)]` are found - introduce the `invalid_doc_attributes` lint (warn-by-default) which triggers: - if a crate-level attribute is used on a non-`crate` item - if `#[doc(inline)]`/`#[doc(no_inline)]` is used on a non-`use` item The code could probably be improved but I wanted to get feedback first. Also, some of those changes could be considered breaking changes, so I don't know what the procedure would be? ~~And finally, for the warnings, they are currently hard warnings, maybe it would be better to introduce a lint?~~ (EDIT: introduced the `invalid_doc_attributes` lint) Closes #80275. r? `@jyn514`
2021-05-11add missing windows testsMichael Hall-53/+140
2021-05-11add file_prefix methodMichael Hall-36/+191
2021-05-11Remove an invalid `#[doc(inline)]`LeSeulArtichaut-1/+0
2021-05-10io::Seek::rewind: Set tracking issueIan Jackson-1/+1
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10Fix typo in docIan Jackson-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-10io::Seek: Provide rewind()Ian Jackson-0/+35
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10io::Seek: Mention that seeking can fail due to buffer flush failIan Jackson-0/+2
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-10change k to key and v to v in std::env modshirshak55-10/+10
2021-05-10windows: provide NonZeroDWORDIan Jackson-0/+2
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-09remove const_fn feature gateRalf Jung-1/+0
2021-05-07Revert SGX inline asm syntaxJethro Beekman-8/+8
This was erroneously changed in #83387
2021-05-07panic/fork test: Do not run on emscriptenIan Jackson-0/+1
fork fails there. The failure message is confusing: so c.status() returns an Err, the closure panics, and the test thinks the panic was propagated from inside the child. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07Rollup merge of #85030 - jethrogb:jb/sgx-rearrange-files, r=nagisaDylan DPC-6/+7
Rearrange SGX split module files In #75979 several inlined modules were split out into multiple files. This PR keeps the multiple files but moves a few things around to organize things in a coherent way.
2021-05-07Rollup merge of #85029 - jethrogb:jb/sgx-movable-mutex, r=m-ou-seDylan DPC-1/+1
SGX mutex is movable r? ``@m-ou-se``
2021-05-07Rollup merge of #84655 - CDirkx:wasm, r=m-ou-seDylan DPC-65/+14
Cleanup of `wasm` Some more cleanup of `sys`, this time `wasm` - Reuse `unsupported::args` (functionally equivalent implementation, just an empty iterator). - Split out `atomics` implementation of `wasm::thread`, the non-`atomics` implementation is reused from `unsupported`. - Move all of the `atomics` code to a separate directory `wasm/atomics`. ````@rustbot```` label: +T-libs-impl r? ````@m-ou-se````
2021-05-07Rearrange SGX split module filesJethro Beekman-6/+7
In #75979 several inlined modules were split out into multiple files. This PR keeps the multiple files but moves a few things around to organize things in a coherent way.
2021-05-07SGX mutex is movableJethro Beekman-1/+1
2021-05-07panic ui test: Provide comprehensive test for panic after forkIan Jackson-0/+3
This tests that we can indeed safely panic after fork, both a raw libc::fork and in a Command pre_exec hook. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07panic tests: Command: Test that we do not unwind past forkIan Jackson-0/+23
This is safe (does not involve heap allocation) but we don't yet have a test to ensure that stays true. That will come in a moment. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07unix process: pre_exec: Discuss panic safetyIan Jackson-0/+6
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07panic/fork: Command: Do not unwind after fork() in childIan Jackson-0/+1
Unwinding after fork() in the child is UB on some platforms, because on those (including musl) malloc can be UB in the child of a multithreaded program, and unwinding must box for the payload. Even if it's safe, unwinding past fork() in the child causes whatever traps the unwind to return twice. This is very strange and clearly not desirable. With the default behaviour of the thread library, this can even result in a panic in the child being transformed into zero exit status (ie, success) as seen in the parent! Fixes #79740. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-07std panicking: ALWAYS_ABORT: use Relaxed memory orderingIan Jackson-2/+2
As per https://github.com/rust-lang/rust/pull/81858#discussion_r626507810 Suggested-by: Mara Bos <m-ou.se@m-ou.se> Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-07std panicking: Provide panic::always_abortIan Jackson-15/+85
We must change the atomic read on panic entry to `Acquire`, to pick up a possible an `always_panic` on another thread. We add `count` to the names of panic_count::get and ::is_zaero, because now there is another reason why panic ought to maybe abort. Renaming these ensures that we have checked every call site to ensure that they don't need further adjustment. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk> Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2021-05-07std panicking: Make decrease() return ()Ian Jackson-2/+2
Nothing uses the return value. This will make the next changes easier. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-07Rollup merge of #84409 - mzohreva:mz/tls-dtors-before-join, r=jethrogbDylan DPC-10/+173
Ensure TLS destructors run before thread joins in SGX The excellent test is from ```@jethrogb``` For context see: https://github.com/rust-lang/rust/pull/83416#discussion_r617282907
2021-05-06Auto merge of #79930 - tgnottingham:bufwriter_performance, r=m-ou-sebors-39/+178
Optimize BufWriter
2021-05-06Add additional migrations to handle auto-traits and clone traitsRoxane-0/+2
Combine all 2229 migrations under one flag name
2021-05-06join_orders_after_tls_destructors: ensure thread 2 is launched before thread ↵Mohsen Zohrevandi-8/+9
1 enters TLS destructors
2021-05-06Rollup merge of #84712 - joshtriplett:simplify-chdir, r=yaahcDylan DPC-5/+3
Simplify chdir implementation and minimize unsafe block
2021-05-06Rollup merge of #84328 - Folyd:stablize_map_into_keys_values, r=m-ou-seDylan DPC-18/+12
Stablize {HashMap,BTreeMap}::into_{keys,values} I would propose to stabilize `{HashMap,BTreeMap}::into_{keys,values}`( aka. `map_into_keys_values`). Closes #75294.
2021-05-06Use the proper import library namesChris Denton-168/+167
2021-05-06Add `#[link]` attributes to dll importsChris Denton-0/+3
This avoids using jmp stubs when calling functions exported from a dll.
2021-05-05Auto merge of #84956 - RalfJung:rollup-m70mx2n, r=RalfJungbors-1/+22
Rollup of 11 pull requests Successful merges: - #83553 (Update `ptr` docs with regards to `ptr::addr_of!`) - #84183 (Update RELEASES.md for 1.52.0) - #84709 (Add doc alias for `chdir` to `std::env::set_current_dir`) - #84803 (Reduce duplication in `impl_dep_tracking_hash` macros) - #84808 (Account for unsatisfied bounds in E0599) - #84843 (use else if in std library ) - #84865 (rustbuild: Pass a `threads` flag that works to windows-gnu lld) - #84878 (Clarify documentation for `[T]::contains`) - #84882 (platform-support: Center the contents of the `std` and `host` columns) - #84903 (Remove `rustc_middle::mir::interpret::CheckInAllocMsg::NullPointerTest`) - #84913 (Do not ICE on invalid const param) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-05-05Rollup merge of #84709 - joshtriplett:doc-alias-chdir, r=dtolnayRalf Jung-0/+1
Add doc alias for `chdir` to `std::env::set_current_dir` Searching for `chdir` in the Rust documentation produces no useful results. I wrote some code recently that called `libc::chdir` and manually handled errors, because I didn't realize that the safe `std::env::set_current_dir` existed. I searched for `chdir` and `change_dir` and `change_directory` (the latter two based on the precedent of unabbreviating set by `create_dir`), and I also read through `std::fs` expecting to potentially find it there. Given that none of those led to `std::env::set_current_dir`, I think that provides sufficient justification to add this specific alias.
2021-05-05Rollup merge of #83553 - jfrimmel:addr-of, r=m-ou-seRalf Jung-1/+21
Update `ptr` docs with regards to `ptr::addr_of!` This updates the documentation since `ptr::addr_of!` and `ptr::addr_of_mut!` are now stable. One might remove the distinction between the sections `# On packed structs` and `# Examples`, as the old section on packed structs was primarily to prevent users of doing undefined behavior, which is not necessary anymore. Technically there is now wrong/outdated documentation on stable, but I don't think this is worth a point release 😉 Fixes #83509. ``````````@rustbot`````````` modify labels: T-doc
2021-05-05Bump map_into_keys_values stable version to 1.54.0.Mara Bos-12/+12
2021-05-05Auto merge of #84200 - CDirkx:os, r=m-ou-sebors-190/+161
Move all `sys::ext` modules to `os` This PR moves all `sys::ext` modules to `os`, centralizing the location of all `os` code and simplifying the dependencies between `os` and `sys`. Because this also removes all uses `cfg_if!` on publicly exported items, where after #81969 there were still a few left, this should properly work around https://github.com/rust-analyzer/rust-analyzer/issues/6038. `@rustbot` label: +T-libs-impl
2021-05-03Update `ptr` docs with regards to `ptr::addr_of!`Julian Frimmel-1/+21
This updates the documentation since `ptr::addr_of!` and `ptr::addr_of_mut!` are now stable. One might remove the distinction between the sections `# On packed structs` and `# Examples`, as the old section on packed structs was primarily to prevent users of doing unde- fined behavior, which is not necessary anymore. There is also a new section in "how to obtain a pointer", which referen- ces the `ptr::addr_of!` macros. This commit contains squashed commits from code review. Co-authored-by: Joshua Nelson <joshua@yottadb.com> Co-authored-by: Mara Bos <m-ou.se@m-ou.se> Co-authored-by: Soveu <marx.tomasz@gmail.com> Co-authored-by: Ralf Jung <post@ralfj.de>
2021-05-03Allow documenting on `hermit`Christiaan Dirkx-3/+0
2021-05-03Rework `os` to avoid using `cfg_if!` with public itemsChristiaan Dirkx-123/+151
2021-05-03Move `std::sys::sgx::ext` to `std::os::fortanix_sgx`Christiaan Dirkx-8/+4
2021-05-03Move `std::sys::wasi::ext` to `std::os::wasi`Christiaan Dirkx-26/+2