about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2023-12-18Rollup merge of #119051 - ChrisDenton:wine, r=workingjubileeMatthias Krüger-6/+8
Replace `FileAllocationInfo` with `FileEndOfFileInfo` This fixes WINE support
2023-12-17Auto merge of #114962 - darklyspaced:debug, r=est31bors-3/+3
adds a column number to `dbg!()` this would be very nice to have for a few reasons: 1. the rfc, when deciding not to add column numbers to macro, failed to acknowledge any potential ambiguous cases -- such as the one provided in #114910 -- which do exist 2. would be able to consistently and easily jump directly to the `dbg!()` regardless of the sutation 3. takes up, at a maximum, 3 characters of _horizontal_ screen space fixes #114910
2023-12-17Use FileEndOfFileInfo, not FileAllocationInfoChris Denton-6/+8
This fixes WINE support
2023-12-15Rollup merge of #118851 - bzEq:std-xcoff, r=Mark-SimulacrumJubilee-0/+5
[std] Add xcoff in object's feature list object-0.32.0 has supported XCOFF format. And backtrace in submodule has been updated to support XCOFF and AIX. Add `xcoff` to supported feature list to make backtrace built on AIX.
2023-12-15Rollup merge of #118396 - compiler-errors:ast-lang-items, r=cjgillotJubilee-5/+5
Collect lang items from AST, get rid of `GenericBound::LangItemTrait` r? `@cjgillot` cc #115178 Looking forward, the work to remove `QPath::LangItem` will also be significantly more difficult, but I plan on doing it as well. Specifically, we have to change: 1. A lot of `rustc_ast_lowering` for things like expr `..` 2. A lot of astconv, since we actually instantiate lang and non-lang paths quite differently. 3. A ton of diagnostics and clippy lints that are special-cased via `QPath::LangItem` Meanwhile, it was pretty easy to remove `GenericBound::LangItemTrait`, so I just did that here.
2023-12-15Stabilize `ptr::{from_ref, from_mut}`Maybe Waffle-1/+0
2023-12-15Cfg remove lang items in doctestCameron Steffen-5/+5
2023-12-15Auto merge of #118966 - matthiaskrgr:rollup-sdvjwy6, r=matthiaskrgrbors-10/+40
Rollup of 3 pull requests Successful merges: - #116888 (Add discussion that concurrent access to the environment is unsafe) - #118888 (Uplift `TypeAndMut` and `ClosureKind` to `rustc_type_ir`) - #118929 (coverage: Tidy up early parts of the instrumentor pass) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-15Rollup merge of #116888 - tbu-:pr_unsafe_env, r=AmanieuMatthias Krüger-10/+40
Add discussion that concurrent access to the environment is unsafe The bug report #27970 has existed for 8 years, the actual bug dates back to Rust pre-1.0. I documented it since it's in the interest of the user to be aware of it. The note can be removed once #27970 is fixed.
2023-12-15Auto merge of #118770 - saethlin:fix-inline-never-uses, r=nnethercotebors-1/+0
Fix cases where std accidentally relied on inline(never) This PR increases the power of `-Zcross-crate-inline-threshold=always` so that it applies through `#[inline(never)]`. Note that though this is called "cross-crate-inlining" in this case especially it is _just_ lazy per-CGU codegen. The MIR inliner and LLVM still respect the attribute as much as they ever have. Trying to bootstrap with the new `-Zcross-crate-inline-threshold=always` change revealed two bugs: We have special intrinsics `assert_inhabited`, `assert_zero_valid`, and `assert_mem_uniniitalized_valid` which codegen backends will lower to nothing or a call to `panic_nounwind`. Since we may not have any call to `panic_nounwind` in MIR but emit one anyway, we need to specially tell `MirUsedCollector` about this situation. `#[lang = "start"]` is special-cased already so that `MirUsedCollector` will collect it, but then when we make it cross-crate-inlinable it is only assigned to a CGU based on whether `MirUsedCollector` saw a call to it, which of course we didn't. --- I started looking into this because https://github.com/rust-lang/rust/pull/118683 revealed a case where we were accidentally relying on a function being `#[inline(never)]`, and cranking up cross-crate-inlinability seems like a way to find other situations like that. r? `@nnethercote` because I don't like what I'm doing to the CGU partitioning code here but I can't come up with something much better
2023-12-14Fix cases where std accidentally relied on inline(never)Ben Kimock-1/+0
2023-12-14Auto merge of #118566 - klensy:cstr-new, r=WaffleLapkinbors-26/+26
use c literals in compiler and library Relands refreshed https://github.com/rust-lang/rust/pull/111647
2023-12-13Reformulate `std::env::{set,remove}_env` as safety noteTobias Bucher-24/+36
2023-12-13Auto merge of #116438 - ChrisDenton:truncate, r=thomccbors-7/+53
Windows: Allow `File::create` to work on hidden files This makes `OpenOptions::new().write(true).create(true).truncate(true).open(&path)` work if the path exists and is a hidden file. Previously it would fail with access denied. This makes it consistent with `OpenOptions::new().write(true).truncate(true).open(&path)` (note the lack of `create`) which does not have this restriction. It's also more consistent with other platforms. Fixes #115745 (see that issue for more details).
2023-12-13Use different cfg for AIXKai Luo-1/+6
2023-12-12added column number to dbg!()darklyspaced-3/+3
2023-12-12Add xcoff supportKai Luo-1/+1
2023-12-10Remove an allocation in min_stackAlex Saveau-1/+1
Signed-off-by: Alex Saveau <saveau.alexandre@gmail.com>
2023-12-10Auto merge of #118692 - surechen:remove_unused_imports, r=petrochenkovbors-18/+3
remove redundant imports detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR. r? `@petrochenkov`
2023-12-10remove redundant importssurechen-18/+3
detects redundant imports that can be eliminated. for #117772 : In order to facilitate review and modification, split the checking code and removing redundant imports code into two PR.
2023-12-10Fix typo in `std::sync::Mutex` examplenaglis-1/+1
2023-12-09Auto merge of #117873 - quininer:android-emutls, r=Amanieubors-1/+7
Add emulated TLS support This is a reopen of https://github.com/rust-lang/rust/pull/96317 . many android devices still only use 128 pthread keys, so using emutls can be helpful. Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls. r? `@Amanieu`
2023-12-08OnceLock: Rework example, statics aren't droppedIan Rees-14/+25
2023-12-07Auto merge of #116565 - Sword-Destiny:master, r=Amanieubors-6/+1170
add teeos std impl add teeos std library implement. this MR is draft untill the libc update to 0.2.150 this MR is the final step for suppot rust in teeos. first step(add target): https://github.com/rust-lang/rust/pull/113480 second step(add teeos libc): https://github.com/rust-lang/libc/pull/3333
2023-12-07add teeos std impl袁浩-6/+1170
Signed-off-by: 袁浩 <yuanhao34@huawei.com>
2023-12-07Add emulated TLS supportquininer-1/+7
Currently LLVM uses emutls by default for some targets (such as android, openbsd), but rust does not use it, because `has_thread_local` is false. This commit has some changes to allow users to enable emutls: 1. add `-Zhas-thread-local` flag to specify that std uses `#[thread_local]` instead of pthread key. 2. when using emutls, decorate symbol names to find thread local symbol correctly. 3. change `-Zforce-emulated-tls` to `-Ztls-model=emulated` to explicitly specify whether to generate emutls.
2023-12-06library: fix comment about const assert in win apiklensy-1/+1
2023-12-06Auto merge of #118655 - compiler-errors:rollup-vrngyzn, r=compiler-errorsbors-1/+1
Rollup of 9 pull requests Successful merges: - #117793 (Update variable name to fix `unused_variables` warning) - #118123 (Add support for making lib features internal) - #118268 (Pretty print `Fn<(..., ...)>` trait refs with parentheses (almost) always) - #118346 (Add `deeply_normalize_for_diagnostics`, use it in coherence) - #118350 (Simplify Default for tuples) - #118450 (Use OnceCell in cell module documentation) - #118585 (Fix parser ICE when recovering `dyn`/`impl` after `for<...>`) - #118587 (Cleanup error handlers some more) - #118642 (bootstrap(builder.rs): Don't explicitly warn against `semicolon_in_expressions_from_macros`) r? `@ghost` `@rustbot` modify labels: rollup
2023-12-06Auto merge of #117072 - betrusted-io:unwinding-crate-support, r=cuviperbors-1/+29
Use `unwinding` crate for unwinding on Xous platform This patch adds support for using [unwinding](https://github.com/nbdd0121/unwinding) on platforms where libunwinding isn't viable. An example of such a platform is `riscv32imac-unknown-xous-elf`. ### Background The Rust project maintains a fork of llvm at [llvm-project](https://github.com/rust-lang/llvm-project/) where it applies patches on top of the llvm project. This mostly seems to be to get unwinding support for the SGX project, and there may be other patches that I'm unaware of. There is a lot of machinery in the build system to support compiling `libunwind` on other platforms, and I needed to add additional patches to llvm in order to add support for Xous. Rather than continuing down this path, it seemed much easier to use a Rust-based library. The `unwinding` crate by `@nbdd0121` fits this description perfectly. ### Future work This could potentially replace the custom patches for `libunwind` on other platforms such as SGX, and could enable unwinding support on many more exotic platforms. ### Anti-goals This is not designed to replace `libunwind` on tier-one platforms or those where unwinding support already exists. There is already a well-established approach for unwinding there. Instead, this aims to enable unwinding on new platforms where C++ code may be difficult to compile.
2023-12-06std: xous: take eh_frame address from main argsSean Cross-1/+28
The main() function takes an argument that contains the eh_frame address. Implement `unwinding` support by looking for unwinding data at this address. Signed-off-by: Sean Cross <sean@xobs.io>
2023-12-06Auto merge of #118547 - alexcrichton:invert-common-net-inclusion, ↵bors-8/+8
r=workingjubilee std: Invert logic for inclusion of `sys_common::net` The `library/std/src/sys_common/net.rs` module is intended to define common implementations of networking-related APIs across a variety of platforms that share similar APIs (e.g. Berkeley-style sockets and all). This module is not included for more fringe targets however such as UEFI or "unknown" targets to libstd (those classified as `restricted-std`). Previously the `sys_common/net.rs` file was set up such that an allow-list indicated it shouldn't be used. This commit inverts the logic to have an allow-list of when it should be used instead. The goal of this commit is to make it a bit easier to experiment with a new Rust target. Currently more esoteric targets are required to get an exception in this `cfg_if` block to use `crate::sys::net` such as for unsupported targets. With this inversion of logic only targets which actually support networking will be listed, where most of those are lumped under `cfg(unix)`. Given that this change is likely to cause some breakage for some target by accident I've attempted to be somewhat robust with this by following these steps to defining the new predicate for inverted logic. 1. Take all supported targets and filter out all `cfg(unix)` ones as these should all support `sys_common/net.rs`. 2. Take remaining targets and filter out `cfg(windows)` ones. 3. The remaining dozen-or-so targets were all audited by hand. Mostly this included `target_os = "hermit"` and `target_os = "solid_asp3"` which required an allow-list entry, but remaining targets were all already excluded (didn't use `sys_common/net.rs` so they were left out. If this causes breakage it should be relatively easy to fix and I'd be happy to follow-up with any PRs necessary.
2023-12-05Rollup merge of #117793 - wdunicornpro:patch-1, r=workingjubileeMichael Goulet-1/+1
Update variable name to fix `unused_variables` warning This PR fixes an `unused_variables` warning within `os.rs` when targeting `espidf`.
2023-12-03library: use c string literalsklensy-26/+26
2023-12-03Auto merge of #118487 - RalfJung:exposed-provenance, r=thomccbors-0/+1
move exposed-provenance APIs into separate feature gate We have already stated explicitly for all the 'exposed' functions that > Using this method means that code is *not* following strict provenance rules. However, they were part of the same feature gate and still described as part of the strict provenance experiment. Unfortunately, their semantics are much less clear and certainly nowhere near stabilization, so in preparation for an attempt to stabilize the strict provenance APIs, I suggest we split the things related to "exposed" into their own feature gate. I also used this opportunity to better explain how Exposed Provenance fits into the larger plan here: this is *one possible candidate* for `as` semantics, but we don't know if it is actually viable, so we can't really promise that it is equivalent to `as`. If it works out we probably want to make `as` equivalent to the 'exposed' APIs; if it doesn't, we will remove them again and try to find some other semantics for `as`.
2023-12-02Auto merge of #118484 - blyxxyz:os-str-slice, r=BurntSushibors-2/+131
Add substring API for `OsStr` This adds a method for taking a substring of an `OsStr`, which in combination with [`OsStr::as_encoded_bytes()`](https://doc.rust-lang.org/std/ffi/struct.OsStr.html#method.as_encoded_bytes) makes it possible to implement most string operations in safe code. API: ```rust impl OsStr { pub fn slice_encoded_bytes<R: ops::RangeBounds<usize>>(&self, range: R) -> &Self; } ``` Motivation, examples and research at https://github.com/rust-lang/libs-team/issues/306. Tracking issue: #118485 cc `@epage` r? libs-api
2023-12-02std: Invert logic for inclusion of `sys_common::net`Alex Crichton-8/+8
The `library/std/src/sys_common/net.rs` module is intended to define common implementations of networking-related APIs across a variety of platforms that share similar APIs (e.g. Berkeley-style sockets and all). This module is not included for more fringe targets however such as UEFI or "unknown" targets to libstd (those classified as `restricted-std`). Previously the `sys_common/net.rs` file was set up such that an allow-list indicated it shouldn't be used. This commit inverts the logic to have an allow-list of when it should be used instead. The goal of this commit is to make it a bit easier to experiment with a new Rust target. Currently more esoteric targets are required to get an exception in this `cfg_if` block to use `crate::sys::net` such as for unsupported targets. With this inversion of logic only targets which actually support networking will be listed, where most of those are lumped under `cfg(unix)`. Given that this change is likely to cause some breakage for some target by accident I've attempted to be somewhat robust with this by following these steps to defining the new predicate for inverted logic. 1. Take all supported targets and filter out all `cfg(unix)` ones as these should all support `sys_common/net.rs`. 2. Take remaining targets and filter out `cfg(windows)` ones. 3. The remaining dozen-or-so targets were all audited by hand. Mostly this included `target_os = "hermit"` and `target_os = "solid_asp3"` which required an allow-list entry, but remaining targets were all already excluded (didn't use `sys_common/net.rs` so they were left out. If this causes breakage it should be relatively easy to fix and I'd be happy to follow-up with any PRs necessary.
2023-12-02Auto merge of #118077 - calebzulawski:sync-portable-simd-2023-11-19, ↵bors-1/+2
r=workingjubilee Portable SIMD subtree update Syncs nightly to the latest changes from rust-lang/portable-simd r? `@rust-lang/libs`
2023-12-02Add substring API for `OsStr`Jan Verbeek-2/+131
2023-12-01Auto merge of #117248 - ChrisDenton:ci-symlink, r=m-ou-sebors-1/+1
Error if symlinks are not supported in CI In CI we want to run as many tests as possible and be alerted if a test isn't run for any reason.
2023-11-30move exposed-provenance APIs into separate feature gate and explain the ↵Ralf Jung-0/+1
relationship of Exposed Provenance and Strict Provenance
2023-11-29Rollup merge of #116839 - joboet:xous_thread_parking, r=m-ou-seMatthias Krüger-1/+95
Implement thread parking for xous This follows the pattern set by [the Windows parker](https://github.com/rust-lang/rust/blob/ddef56d5dfa18f169af9db912dc8e8343797eebb/library/std/src/sys/windows/thread_parking.rs) when it uses keyed events. An atomic variable is used to track the state and optimize the fast path, while notifications are send via the ticktime server to block and unblock the thread. ping `@xobs` `@rustbot` label +T-libs +A-atomic r? libs
2023-11-28Rollup merge of #118222 - the8472:copy-use-vec-write, r=m-ou-seMatthias Krüger-107/+91
unify read_to_end and io::copy impls for reading into a Vec This ports over the initial probe (to avoid allocation) and the dynamic read sizing from the io::copy specialization to the `default_read_to_end` implementation which already had its own optimizations for different cases. I think it should be a best-of-both now. suggested by `@a1phyr` in https://github.com/rust-lang/rust/pull/117576#issuecomment-1803408492
2023-11-28Rollup merge of #118193 - max-heller:command-typo, r=m-ou-seMatthias Krüger-1/+1
Add missing period in `std::process::Command` docs
2023-11-28Rollup merge of #118299 - frewsxcv:patch-2, r=cuviperMatthias Krüger-9/+41
Update `OnceLock` documentation to give a concrete 'lazy static' example, and expand on the existing example.
2023-11-26unify read_to_end and io::copy impls for reading into a VecThe 8472-107/+91
2023-11-26Use inner docs to fix linksCaleb Zulawski-1/+2
2023-11-26Clean dead codesr0cky-8/+0
2023-11-25Update `OnceLock` documentation to give a concrete 'lazy static' example, ↵Corey Farwell-9/+41
and expand on existing example.
2023-11-24Rollup merge of #118060 - ChrisDenton:abs-device-path, r=thomccMatthias Krüger-1/+1
Use an absolute path to the NUL device While a bare "NUL" *should* be redirected to the NUL device, especially in this simple case, let's be explicit that we aren't opening a file called "NUL" and instead open it directly. This will also set a good example for people copying std code. r? libs
2023-11-24Rollup merge of #117656 - ChrisDenton:invalid, r=thomccMatthias Krüger-7/+8
Update windows-bindgen and define `INVALID_HANDLE_VALUE` ourselves We generate bindings to the Windows API via the `windows-bindgen` crate, which is ultimately what's also used to generate the `windows-sys` and `windows` crates. However, there currently is some custom sauce just for std which makes it a bit different from the vanilla bindings. I would love for us to reduce and eventually remove the differences entirely so that std is using the exact same bindings as everyone else. Maybe in the future we can even just have a normal dependency on `windows-sys`. This PR removes one of those special things. Our definition of `INVALID_HANDLE_VALUE` relies on an experimental nightly feature for strict provenance, so lets bring that back in house. It also excludes it from the codegen step though that isn't strictly necessary as we override it in any case. This PR also updates windows-bingen to 0.52.0.