about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-12-23Adjust the std library for sanitizer_cfi cfgs changesUrgau-1/+2
2023-12-22update cfg(bootstrap)sPietro Albini-1/+0
2023-12-22update version placeholdersPietro Albini-1/+1
2023-12-20stabilize `file_create_new`Ralph Ursprung-3/+1
closes #105135
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 #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-12added column number to dbg!()darklyspaced-3/+3
2023-12-11Updating fs::read example to remove SocketAddressHaydon Ryan-2/+2
2023-12-11fixing error std::fs::read_to_string example documentationHaydon Ryan-2/+2
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-10Use AtomicU8 instead of AtomicUsize in backtrace.rsDavid Thomas-3/+3
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-09merge core_panic feature into panic_internalsRalf Jung-2/+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-08std: getrandom simplification for freebsd.David Carlier-11/+1
it is in the libcs' crate too now.
2023-12-08OnceLock: Rework example, statics aren't droppedIan Rees-14/+25
2023-12-07Auto merge of #116565 - Sword-Destiny:master, r=Amanieubors-6/+1169
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/+1169
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-05fmtZachary S-4/+1
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-05Specify behavior if the closure passed to *Guard::*map panics.Zachary S-69/+364
2023-12-05fix MappedMutexGuard::(try_)map doc typo.Zachary S-2/+2
2023-12-05Add MappedMutexGuard and MappedRwLock*Guard tests.Zachary S-2/+133
2023-12-05Fix Condvar typo, add public re-exports of Mapped*Guard.Zachary S-2/+6
2023-12-05Add comment about `Mapped(Mutex|RwLockWrite)Guard` variance.Zachary S-35/+43
2023-12-05Implmement `MappedRwLock(Read|Write)Guard`.Zachary S-3/+355
2023-12-05Implement `MappedMutexGuard`.Zachary S-0/+193
2023-12-05Allow cloning `poison::Guard`s.Zachary S-0/+1
(makes implementing `Mapped*Guard` easier)
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-04Specialize `count` tooBenoît du Garreau-0/+44
2023-12-04`HashMap`/`HashSet`: forward `fold` implementations of iteratorsBenoît du Garreau-0/+130
2023-12-03library: use c string literalsklensy-26/+26