about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2021-05-21Auto merge of #85060 - ChrisDenton:win-file-exists, r=yaahcbors-8/+72
Windows implementation of feature `path_try_exists` Draft of a Windows implementation of `try_exists` (#83186). The first commit reorganizes the code so I would be interested to get some feedback on if this is a good idea or not. It moves the `Path::try_exists` function to `fs::exists`. leaving the former as a wrapper for the latter. This makes it easier to provide platform specific implementations and matches the `fs::metadata` function. The other commit implements a Windows specific variant of `exists`. I'm still figuring out my approach so this is very much a first draft. Eventually this will need some more eyes from knowledgable Windows people.
2021-05-20doc: clarify Mutex::try_lock, etc. errorsTaylor Yu-9/+28
Clarify error returns from Mutex::try_lock, RwLock::try_read, RwLock::try_write to make it more obvious that both poisoning and the lock being already locked are possible errors.
2021-05-20Auto merge of #85521 - alexcrichton:less-tls-inline, r=Mark-Simulacrumbors-13/+13
std: Don't inline TLS accessor on MinGW This is causing [issues] on Cargo's own CI for MinGW and given the original investigation there's no reason that MinGW should work when MSVC doesn't, this this tweaks the MSVC exception to being a Windows exception. [issues]: https://github.com/rust-lang/cargo/runs/2626676503?check_suite_focus=true#step:9:2453
2021-05-20std: Don't inline TLS accessor on MinGWAlex Crichton-13/+13
This is causing [issues] on Cargo's own CI for MinGW and given the original investigation there's no reason that MinGW should work when MSVC doesn't, this this tweaks the MSVC exception to being a Windows exception. [issues]: https://github.com/rust-lang/cargo/runs/2626676503?check_suite_focus=true#step:9:2453
2021-05-20Rollup merge of #85275 - CDirkx:memchr, r=m-ou-seGuillaume Gomez-8/+10
Move `std::memchr` to `sys_common` `std::memchr` is a thin abstraction over the different `memchr` implementations in `sys`, along with documentation and tests. The module is only used internally by `std`, nothing is exported externally. Code like this is exactly what the `sys_common` module is for, so this PR moves it there.
2021-05-20Auto merge of #84665 - adamgemmell:aarch64-features, r=Amanieubors-1/+0
Update list of allowed aarch64 features I recently added these features to std_detect for aarch64 linux, pending [review](https://github.com/rust-lang/stdarch/pull/1146). I have commented any features not supported by LLVM 9, the current minimum version for Rust. Some (PAuth at least) were renamed between 9 & 12 and I've left them disabled. TME, however, is not in LLVM 9 but I've left it enabled. See https://github.com/rust-lang/stdarch/issues/993
2021-05-20Auto merge of #85486 - RalfJung:rollup-4ibcxuu, r=RalfJungbors-0/+1
Rollup of 8 pull requests Successful merges: - #84717 (impl FromStr for proc_macro::Literal) - #85169 (Add method-toggle to <details> for methods) - #85287 (Expose `Concurrent` (private type in public i'face)) - #85315 (adding time complexity for partition_in_place iter method) - #85439 (Add diagnostic item to `CStr`) - #85464 (Fix UB in documented example for `ptr::swap`) - #85470 (Fix invalid CSS rules for a:hover) - #85472 (CTFE Machine: do not expose Allocation) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-05-20Auto merge of #84697 - CDirkx:util, r=m-ou-sebors-46/+34
Introduce `sys_common::rt::rtprintpanic!` to replace `sys_common::util` functionality This PR introduces a new macro `rtprintpanic!`, similar to `sys_common::util::dumb_print` and uses that macro to replace all `sys_common::util` functionality.
2021-05-20Not implement `os::unix::fs::chroot` for `vxworks`Christiaan Dirkx-2/+2
2021-05-20Add `ExitStatusError` for `vxworks`Christiaan Dirkx-3/+29
2021-05-19Windows implementation of `fs::try_exists`Chris Denton-1/+30
2021-05-19Move the implementation of `Path::exists` to `sys_common::fs` so platforms ↵Chris Denton-8/+43
can specialize it Windows implementation of `fs::try_exists`
2021-05-19Windows `Command` environment variables are case-preservingChris Denton-9/+128
But comparing is case-insensitive.
2021-05-20Rollup merge of #85439 - mgacek8:add_diagnostic_item_to_CStr_type, r=davidtwcoRalf Jung-0/+1
Add diagnostic item to `CStr` Required for clippy issue: https://github.com/rust-lang/rust-clippy/issues/7145
2021-05-19Auto merge of #84876 - alexcrichton:inline-thread-locals-cross-crate, ↵bors-0/+24
r=Mark-Simulacrum std: Attempt again to inline thread-local-init across crates Issue #25088 has been part of `thread_local!` for quite some time now. Historical attempts have been made to add `#[inline]` to `__getit` in #43931, #50252, and #59720, but these attempts ended up not landing at the time due to segfaults on Windows. In the interim though with `const`-initialized thread locals AFAIK this is the only remaining bug which is why you might want to use `#[thread_local]` over `thread_local!`. As a result I figured it was time to resubmit this and see how it fares on CI and if I can help debugging any issues that crop up. Closes #25088
2021-05-19Remove test for crypto feature ahead of its removalAdam Gemmell-1/+0
2021-05-19Rename `rterr` to `rtprintpanic`Christiaan Dirkx-11/+12
2021-05-19Replace `sys_common::util::dumb_print` with `rterr!`Christiaan Dirkx-18/+6
2021-05-19Replace `sys_common::util::report_overflow` with `rterr!`Christiaan Dirkx-14/+10
2021-05-19Remove `sys_common::util::abort`Christiaan Dirkx-11/+6
2021-05-19Introduce `sys_common::rt::rterr!`Christiaan Dirkx-1/+9
2021-05-19Auto merge of #85458 - jackh726:rollup-zvvybmt, r=jackh726bors-1/+1
Rollup of 8 pull requests Successful merges: - #83366 (Stabilize extended_key_value_attributes) - #83767 (Fix v0 symbol mangling bug) - #84883 (compiletest: "fix" FileCheck with --allow-unused-prefixes) - #85274 (Only pass --[no-]gc-sections if linker is GNU ld.) - #85297 (bootstrap: build cargo only if requested in tools) - #85396 (rustdoc: restore header sizes) - #85425 (Fix must_use on `Option::is_none`) - #85438 (Fix escape handling) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2021-05-18Rollup merge of #83366 - jyn514:stabilize-key-value-attrs, r=petrochenkovJack Huey-1/+1
Stabilize extended_key_value_attributes Closes https://github.com/rust-lang/rust/issues/44732. Closes https://github.com/rust-lang/rust/issues/78835. Closes https://github.com/rust-lang/rust/issues/82768 (by making it irrelevant). # Stabilization report ## Summary This stabilizes using macro expansion in key-value attributes, like so: ```rust #[doc = include_str!("my_doc.md")] struct S; #[path = concat!(env!("OUT_DIR"), "/generated.rs")] mod m; ``` See Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455) for alternatives that were considered and rejected ("why accept no more and no less?") This has been available on nightly since 1.50 with no major issues. ## Notes ### Accepted syntax The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`). Note that decorators and the like may be able to observe other expression forms. ### Expansion ordering Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input. There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work). ## Test cases - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs The feature has also been dogfooded extensively in the compiler and standard library: - https://github.com/rust-lang/rust/pull/83329 - https://github.com/rust-lang/rust/pull/83230 - https://github.com/rust-lang/rust/pull/82641 - https://github.com/rust-lang/rust/pull/80534 ## Implementation history - Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412 - Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121 - Preliminary work to restrict expansion that would conflict with this feature: https://github.com/rust-lang/rust/pull/77271 - Initial implementation: https://github.com/rust-lang/rust/pull/78837 - Fix for an ICE: https://github.com/rust-lang/rust/pull/80563 ## Unresolved Questions ~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~ ## Additional Information There are two workarounds that have a similar effect for `#[doc]` attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons: ```rust macro_rules! forward_inner_docs { ($e:expr => $i:item) => { #[doc = $e] $i }; } forward_inner_docs!(include_str!("lib.rs") => struct S {}); ``` This also works for other attributes (like `#[path = concat!(...)]`). The other is to use `doc(include)`: ```rust #![feature(external_doc)] #[doc(include = "lib.rs")] struct S {} ``` The first works, but is non-trivial for people to discover, and difficult to read and maintain. The second is a strange special-case for a particular use of the macro. This generalizes it to work for any use case, not just including files. I plan to remove `doc(include)` when this is stabilized (https://github.com/rust-lang/rust/pull/82539). The `forward_inner_docs` workaround will still compile without warnings, but I expect it to be used less once it's no longer necessary.
2021-05-19Auto merge of #85176 - a1phyr:impl_clone_from, r=yaahcbors-1/+18
Override `clone_from` for some types Override `clone_from` method of the `Clone` trait for: - `cell::RefCell` - `cmp::Reverse` - `io::Cursor` - `mem::ManuallyDrop` This can bring performance improvements.
2021-05-18std: Attempt again to inline thread-local-init across cratesAlex Crichton-0/+24
Issue #25088 has been part of `thread_local!` for quite some time now. Historical attempts have been made to add `#[inline]` to `__getit` in #43931, #50252, and #59720, but these attempts ended up not landing at the time due to segfaults on Windows. In the interim though with `const`-initialized thread locals AFAIK this is the only remaining bug which is why you might want to use `#[thread_local]` over `thread_local!`. As a result I figured it was time to resubmit this and see how it fares on CI and if I can help debugging any issues that crop up. Closes #25088
2021-05-18fix typoJorge Ferreira-2/+2
2021-05-18Add diagnostic item to `CStr`Mateusz Gacek-0/+1
2021-05-18Auto merge of #82973 - ijackson:exitstatuserror, r=yaahcbors-20/+281
Provide ExitStatusError Closes #73125 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
2021-05-18Stabilize extended_key_value_attributesJoshua Nelson-1/+1
# Stabilization report ## Summary This stabilizes using macro expansion in key-value attributes, like so: ```rust #[doc = include_str!("my_doc.md")] struct S; #[path = concat!(env!("OUT_DIR"), "/generated.rs")] mod m; ``` See the changes to the reference for details on what macros are allowed; see Petrochenkov's excellent blog post [on internals](https://internals.rust-lang.org/t/macro-expansion-points-in-attributes/11455) for alternatives that were considered and rejected ("why accept no more and no less?") This has been available on nightly since 1.50 with no major issues. ## Notes ### Accepted syntax The parser accepts arbitrary Rust expressions in this position, but any expression other than a macro invocation will ultimately lead to an error because it is not expected by the built-in expression forms (e.g., `#[doc]`). Note that decorators and the like may be able to observe other expression forms. ### Expansion ordering Expansion of macro expressions in "inert" attributes occurs after decorators have executed, analogously to macro expressions appearing in the function body or other parts of decorator input. There is currently no way for decorators to accept macros in key-value position if macro expansion must be performed before the decorator executes (if the macro can simply be copied into the output for later expansion, that can work). ## Test cases - https://github.com/rust-lang/rust/blob/master/src/test/ui/attributes/key-value-expansion-on-mac.rs - https://github.com/rust-lang/rust/blob/master/src/test/rustdoc/external-doc.rs The feature has also been dogfooded extensively in the compiler and standard library: - https://github.com/rust-lang/rust/pull/83329 - https://github.com/rust-lang/rust/pull/83230 - https://github.com/rust-lang/rust/pull/82641 - https://github.com/rust-lang/rust/pull/80534 ## Implementation history - Initial proposal: https://github.com/rust-lang/rust/issues/55414#issuecomment-554005412 - Experiment to see how much code it would break: https://github.com/rust-lang/rust/pull/67121 - Preliminary work to restrict expansion that would conflict with this feature: https://github.com/rust-lang/rust/pull/77271 - Initial implementation: https://github.com/rust-lang/rust/pull/78837 - Fix for an ICE: https://github.com/rust-lang/rust/pull/80563 ## Unresolved Questions ~~https://github.com/rust-lang/rust/pull/83366#issuecomment-805180738 listed some concerns, but they have been resolved as of this final report.~~ ## Additional Information There are two workarounds that have a similar effect for `#[doc]` attributes on nightly. One is to emulate this behavior by using a limited version of this feature that was stabilized for historical reasons: ```rust macro_rules! forward_inner_docs { ($e:expr => $i:item) => { #[doc = $e] $i }; } forward_inner_docs!(include_str!("lib.rs") => struct S {}); ``` This also works for other attributes (like `#[path = concat!(...)]`). The other is to use `doc(include)`: ```rust #![feature(external_doc)] #[doc(include = "lib.rs")] struct S {} ``` The first works, but is non-trivial for people to discover, and difficult to read and maintain. The second is a strange special-case for a particular use of the macro. This generalizes it to work for any use case, not just including files. I plan to remove `doc(include)` when this is stabilized. The `forward_inner_docs` workaround will still compile without warnings, but I expect it to be used less once it's no longer necessary.
2021-05-17Rollup merge of #85409 - CDirkx:cfg_redox, r=nagisaRalf Jung-1/+1
Simplify `cfg(any(unix, target_os="redox"))` in example to just `cfg(unix)` Update example for `OsString` that handled `redox` seperately from `unix`: Redox has been completely integrated under `target_family="unix"`, so `cfg(unix)` implies `target_os="redox"` https://github.com/rust-lang/rust/blob/35dbef235048f9a2939dc20effe083ca483c37ff/compiler/rustc_target/src/spec/redox_base.rs#L26
2021-05-17Rollup merge of #85302 - r00ster91:patch-7, r=joshtriplettRalf Jung-1/+1
Expand WASI abbreviation in docs I was pretty sure this was related to something for WebAssembly but wasn't 100% sure so I checked but even on these top-level docs I couldn't find the abbreviation expanded. I'm normally used to Rust docs being detailed and explanatory and writing abbreviations like this out in full at least once so I thought it was worth the change. Feel free to close this if it's too much.
2021-05-17Simplify `cfg(any(unix, target_os="redox"))` to just `cfg(unix)`Christiaan Dirkx-1/+1
2021-05-15Auto merge of #81858 - ijackson:fork-no-unwind, r=m-ou-sebors-17/+121
Do not allocate or unwind after fork ### Objective scenarios * Make (simple) panics safe in `Command::pre_exec_hook`, including most `panic!` calls, `Option::unwrap`, and array bounds check failures. * Make it possible to `libc::fork` and then safely panic in the child (needed for the above, but this requirement means exposing the new raw hook API which the `Command` implementation needs). * In singlethreaded programs, where panic in `pre_exec_hook` is already memory-safe, prevent the double-unwinding malfunction #79740. I think we want to make panic after fork safe even though the post-fork child environment is only experienced by users of `unsafe`, beause the subset of Rust in which any panic is UB is really far too hazardous and unnatural. #### Approach * Provide a way for a program to, at runtime, switch to having panics abort. This makes it possible to panic without making *any* heap allocations, which is needed because on some platforms malloc is UB in a child forked from a multithreaded program (see https://github.com/rust-lang/rust/pull/80263#issuecomment-774272370, and maybe also the SuS [spec](https://pubs.opengroup.org/onlinepubs/9699919799/functions/fork.html)). * Make that change in the child spawned by `Command`. * Document the rules comprehensively enough that a programmer has a fighting chance of writing correct code. * Test that this all works as expected (and in particular, that there aren't any heap allocations we missed) Fixes #79740 #### Rejected (or previously attempted) approaches * Change the panic machinery to be able to unwind without allocating, at least when the payload and message are both `'static`. This seems like it would be even more subtle. Also that is a potentially-hot path which I don't want to mess with. * Change the existing panic hook mechanism to not convert the message to a `String` before calling the hook. This would be a surprising change for existing code and would not be detected by the type system. * Provide a `raw_panic_hook` function to intercept panics in a way that doesn't allocate. (That was an earlier version of this MR.) ### History This MR could be considered a v2 of #80263. Thanks to everyone who commented there. In particular, thanks to `@m-ou-se,` `@Mark-Simulacrum` and `@hyd-dev.` (Tagging you since I think you might be interested in this new MR.) Compared to #80263, this MR has very substantial changes and additions. Additionally, I have recently (2021-04-20) completely revised this series following very helpful comments from `@m-ou-se.` r? `@m-ou-se`
2021-05-15Add doc aliases to `unit`r00ster-0/+3
2021-05-15Rollup merge of #85221 - ijackson:dbg-doc-re-tests, r=joshtriplettGuillaume Gomez-3/+4
dbg macro: Discuss use in tests, and slightly clarify As discussed in a tangent in #82778. I chose to use [semantic newlines](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) in the source text but I don't mind reformatting it.
2021-05-15Rollup merge of #85207 - andrewhalle:typo-rootseparator, r=kennytmGuillaume Gomez-1/+1
Fix typo in comment missing space in "rootseparator"
2021-05-14Expand WASI abbreviation in docsr00ster-1/+1
2021-05-14add an example to explain std::io::Read::read returning 0 in some casesGeoffroy Couprie-1/+7
the example focuses on Linux, but that should be enough to explain how the behaviour can change
2021-05-14Move `std::memchr` to `sys_common`Christiaan Dirkx-8/+10
2021-05-13Update compiler_builtins to 0.1.43Amanieu d'Antras-1/+1
2021-05-13Add support for const operands and options to global_asm!Amanieu d'Antras-2/+2
On x86, the default syntax is also switched to Intel to match asm!
2021-05-13Fix indentation in move keyword documentationThomas Otto-2/+2
2021-05-13Tolerate SIGTRAP for panic abort after panic::always_abortIan Jackson-1/+1
Some platforma (eg ARM64) apparently generate SIGTRAP for panic abort! See eg https://github.com/rust-lang/rust/pull/81858#issuecomment-840702765 This is probably a bug, but we don't want to entangle this MR with it. When it's fixed, this commit should be reverted. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-13Change "etc." to "and similar"Ian Jackson-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>
2021-05-12Auto merge of #84730 - sexxi-goose:rox-auto-trait, r=nikomatsakisbors-0/+2
Add auto traits and clone trait migrations for RFC2229 This PR - renames the existent RFC2229 migration `disjoint_capture_drop_reorder` to `disjoint_capture_migration` - add additional migrations for auto traits and clone trait Closes rust-lang/project-rfc-2229#29 Closes rust-lang/project-rfc-2229#28 r? `@nikomatsakis`
2021-05-12dbg macro: Discuss use in tests, and slightly clarifyIan Jackson-3/+4
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12ExitStatusError: Remove mentions in stable docsIan Jackson-27/+3
We should revert this commit when this is stabilised. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12impl crate::error::Error for ExitStatusErrorIan Jackson-0/+3
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2021-05-12ExitStatusError: Be more verbose in Display implIan Jackson-1/+1
Co-authored-by: Jane Lusby <jlusby@yaah.dev>
2021-05-12Fix typo in docIan Jackson-1/+1
Co-authored-by: Josh Triplett <josh@joshtriplett.org>