about summary refs log tree commit diff
path: root/library/std
AgeCommit message (Collapse)AuthorLines
2024-04-08Rollup merge of #115984 - hermit-os:fuse, r=m-ou-seMatthias Krüger-103/+251
extending filesystem support for Hermit Extending `std` to create, change and read a directory for Hermit. Hermit is a tier 3 platform and this PR changes only files, wich are related to the tier 3 platform.
2024-04-08Add pattern types to parserOli Scherer-0/+6
2024-04-08std: update abort message in `thread::set_current`joboet-1/+1
2024-04-08Auto merge of #123506 - RalfJung:miri-test-libstd, r=Mark-Simulacrumbors-1/+6
check-aux: test core, alloc, std in Miri Let's see if this works, and how long it takes.
2024-04-07sys_common::thread_local_key: make a note that this is not used on WindowsRalf Jung-1/+4
2024-04-07also test parts of stdRalf Jung-1/+6
requires disabling some tests that do not work
2024-04-06Rollup merge of #123541 - RalfJung:remove-old-hacks, r=Mark-SimulacrumGuillaume Gomez-7/+1
remove miri-test-libstd hacks that are no longer needed In https://github.com/rust-lang/rust/pull/123317 we developed a different approach to testing the standard library in Miri, and with https://github.com/rust-lang/miri-test-libstd/pull/56 the out-of-tree miri-test-libstd has been switched to that approach. That makes these hacks here no longer necessary.
2024-04-06Rollup merge of #114788 - tisonkun:get_mut_or_init, r=dtolnayMatthias Krüger-0/+81
impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLock See also https://github.com/rust-lang/rust/issues/74465#issuecomment-1676522051 I'm trying to understand the process for such proposal. And I'll appreciate it if anyone can guide me the next step for consensus or adding tests.
2024-04-06remove miri-test-libstd hacks that are no longer neededRalf Jung-7/+1
2024-04-06Auto merge of #123433 - GnomedDev:remove-threadname-alloc, r=joboetbors-6/+27
Remove rt::init allocation for thread name This removes one of the allocations in a `fn main() {}` program.
2024-04-05Rollup merge of #123505 - ChrisDenton:revert-121666, r=workingjubileeGuillaume Gomez-164/+10
Revert "Use OS thread name by default" This reverts #121666 (Use the OS thread name by default if `THREAD_INFO` has not been initialized) due to #123495 (Thread names are not always valid UTF-8). It's not a direct revert because there have been other changes since that PR.
2024-04-05Rollup merge of #121419 - agg23:xrOS-pr, r=davidtwcoGuillaume Gomez-20/+393
Add aarch64-apple-visionos and aarch64-apple-visionos-sim tier 3 targets Introduces `aarch64-apple-visionos` and `aarch64-apple-visionos-sim` as tier 3 targets. This allows native development for the Apple Vision Pro's visionOS platform. This work has been tracked in https://github.com/rust-lang/compiler-team/issues/642. There is a corresponding `libc` change https://github.com/rust-lang/libc/pull/3568 that is not required for merge. Ideally we would be able to incorporate [this change](https://github.com/gimli-rs/object/pull/626) to the `object` crate, but the author has stated that a release will not be cut for quite a while. Therefore, the two locations that would reference the xrOS constant from `object` are hardcoded to their MachO values of 11 and 12, accompanied by TODOs to mark the code as needing change. I am open to suggestions on what to do here to get this checked in. # Tier 3 Target Policy At this tier, the Rust project provides no official support for a target, so we place minimal requirements on the introduction of targets. > A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.) See [src/doc/rustc/src/platform-support/apple-visionos.md](https://github.com/rust-lang/rust/blob/e88379034a0fe7d90a8f305bbaf4ad66dd2ce8dc/src/doc/rustc/src/platform-support/apple-visionos.md) > Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target. > * Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it. > * If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo. This naming scheme matches `$ARCH-$VENDOR-$OS-$ABI` which is matches the iOS Apple Silicon simulator (`aarch64-apple-ios-sim`) and other Apple targets. > Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users. > - The target must not introduce license incompatibilities. > - Anything added to the Rust repository must be under the standard Rust license (`MIT OR Apache-2.0`). > - The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the `tidy` tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to besubject to any new license requirements. > - Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, `rustc` built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3. > - "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are *not* limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users. This contribution is fully available under the standard Rust license with no additional legal restrictions whatsoever. This PR does not introduce any new dependency less permissive than the Rust license policy. The new targets do not depend on proprietary libraries. > Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions. This new target mirrors the standard library for watchOS and iOS, with minor divergences. > The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary. Documentation is provided in [src/doc/rustc/src/platform-support/apple-visionos.md](https://github.com/rust-lang/rust/blob/e88379034a0fe7d90a8f305bbaf4ad66dd2ce8dc/src/doc/rustc/src/platform-support/apple-visionos.md) > Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions. > * This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements. > Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via `@)` to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages. > * Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications. > Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target. > * In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target. I acknowledge these requirements and intend to ensure that they are met. This target does not touch any existing tier 2 or tier 1 targets and should not break any other targets.
2024-04-05Auto merge of #123317 - RalfJung:test-in-miri, r=m-ou-se,saethlin,onur-ozkanbors-0/+4
Support running library tests in Miri This adds a new bootstrap subcommand `./x.py miri` which can test libraries in Miri. This is in preparation for eventually doing that as part of bors CI, but this PR only adds the infrastructure, and doesn't enable it yet. `@rust-lang/bootstrap` should this be `x.py test --miri library/core` or `x.py miri library/core`? The flag has the advantage that we don't have to copy all the arguments from `Subcommand::Test`. It has the disadvantage that most test steps just ignore `--miri` and still run tests the regular way. For clippy you went the route of making it a separate subcommand. ~~I went with a flag now as that seemed easier, but I can change this.~~ I made it a new subcommand. Note however that the regular cargo invocation would be `cargo miri test ...`, so `x.py` is still going to be different in that the `test` is omitted. That said, we could also make it `./x.py miri-test` to make that difference smaller -- that's in fact more consistent with the internal name of the command when bootstrap invokes cargo. `@rust-lang/libs` ~~unfortunately this PR does some unholy things to the `lib.rs` files of our library crates.~~ `@m-ou-se` found a way that entirely avoids library-level hacks, except for some new small `lib.miri.rs` files that hopefully you will never have to touch. There's a new hack in cargo-miri but there it is in good company...
2024-04-05Revert #121666Chris Denton-164/+10
This reverts #121666 due to #123495
2024-04-05macOS: Use `libc` definitions for copyfileMads Marquart-39/+10
`COPYFILE_ALL` is not yet exposed in `libc`, but the rest of what we need is, so use those definitions instead of manually defining them.
2024-04-04Remove rt::init allocation for thread nameDavid Thomas-6/+27
2024-04-04Rollup merge of #123389 - ChrisDenton:dont-panic-on-startup, r=joboetMatthias Krüger-30/+14
Avoid panicking unnecessarily on startup On Windows, in `lang_start` we add an exception handler to catch stack overflows and we also reserve some stack space for the handler. Both of these are useful but they're not strictly necessary. The standard library has to work without them (e.g. if Rust is used from a foreign entry point) and the negative effect of not doing them is limited (i.e. you don't get the friendly stack overflow message). As we really don't want to panic pre-main unless absolutely necessary, it now won't panic on failure. I've added some debug assertions so as to avoid programmer error.
2024-04-04Add comments about using debug_assertChris Denton-0/+4
2024-04-03Rollup merge of #122356 - devnexen:dfbsd_build_fix, r=jhprattJacob Pratt-7/+13
std::rand: fix dragonflybsd after #121942.
2024-04-03add 'x.py miri', and make it work for 'library/{core,alloc,std}'Ralf Jung-0/+4
2024-04-03rename `expose_addr` to `expose_provenance`joboet-2/+2
2024-04-03std: add comment about abort motivationjoboet-0/+2
2024-04-02Rollup merge of #123388 - tshepang:consistency, r=jhprattJubilee-2/+2
use a consistent style for links
2024-04-02Rollup merge of #122411 - alexcrichton:wasm32-wasip2-cabi-realloc, r=m-ou-seJubilee-9/+70
Provide cabi_realloc on wasm32-wasip2 by default This commit provides a component model intrinsic in the standard library by default on the `wasm32-wasip2` target. This intrinsic is not required by the component model itself but is quite common to use, for example it's needed if a wasm module receives a string or a list. The intention of this commit is to provide an overridable definition in the standard library through a weak definition of this function. That means that downstream crates can provide their own customized and more specific versions if they'd like, but the standard library's version should suffice for general-purpose use.
2024-04-02Rollup merge of #122935 - RalfJung:with-exposed-provenance, r=AmanieuJacob Pratt-7/+7
rename ptr::from_exposed_addr -> ptr::with_exposed_provenance As discussed on [Zulip](https://rust-lang.zulipchat.com/#narrow/stream/136281-t-opsem/topic/To.20expose.20or.20not.20to.20expose/near/427757066). The old name, `from_exposed_addr`, makes little sense as it's not the address that is exposed, it's the provenance. (`ptr.expose_addr()` stays unchanged as we haven't found a better option yet. The intended interpretation is "expose the provenance and return the address".) The new name nicely matches `ptr::without_provenance`.
2024-04-02Avoid panicking unnecessarily on startupChris Denton-30/+10
2024-04-02use a consistent style for linksTshepang Mbambo-2/+2
2024-04-02Document restricted_stdAdam Gemmell-1/+10
This PR aims to pin down exactly what restricted_std is meant to achieve and what it isn't. This commit fixes https://github.com/rust-lang/wg-cargo-std-aware/issues/87 by explaining why the error appears and what the choices the user has. The error describes how std cannot function without knowing about some form of OS/platform support. Any features of std that work without an OS should be moved to core/alloc (see https://github.com/rust-lang/rust/issues/27242 https://github.com/rust-lang/rust/issues/103765). Note that the message says "platform" and "environment" because, since https://github.com/rust-lang/rust/pull/120232, libstd can be built for some JSON targets. This is still unsupported (all JSON targets probably should be unstable https://github.com/rust-lang/wg-cargo-std-aware/issues/90), but a JSON target with the right configuration should hopefully have some partial libstd support. I propose closing https://github.com/rust-lang/wg-cargo-std-aware/issues/69 as "Won't fix" since any support of std without properly configured os, vendor or env fields is very fragile considering future upgrades of Rust or dependencies. In addition there's no likely path to it being fixed long term (making std buildable for all targets being the only solution). This is distinct from tier 3 platforms with limited std support implemented (and as such aren't restricted_std) because these platforms can conceptually work in the future and std support should mainly improve over time. The alternative to closing https://github.com/rust-lang/wg-cargo-std-aware/issues/69 is a new crate feature for std which escapes the restricted_std mechanism in build.rs. It could be used with the -Zbuild-std-features flag if we keep it permanently unstable, which I hope we can do anyway. A minor side-effect in this scenario is that std wouldn't be marked as unstable if documentation for it were generated with build-std.
2024-04-02std: reduce code size of `set_current`joboet-2/+5
2024-04-02style: fmtSteve Lau-1/+2
2024-04-02fix: build on haiku by adding missing importSteve Lau-1/+1
2024-04-01Rollup merge of #123323 - devnexen:thread_set_name_solaris_fix, r=workingjubileeJubilee-1/+6
std::thread: set_name change for solaris/illumos. truncate down to 32 (31 + 1) for solaris/illumos.
2024-04-01std::thread: set_name change for solaris/illumos.David Carlier-1/+6
truncate down to 32 (31 + 1) for solaris/illumos.
2024-04-01Auto merge of #123315 - devnexen:thread_get_name_solaris, r=ChrisDentonbors-3/+11
std::thread: adding get_name implementation for solaris/illumos. THREAD_NAME_MAX is 32 (31 max + 1 for the null terminator).
2024-04-01Auto merge of #123265 - joboet:guardians_of_the_unix, r=ChrisDentonbors-490/+317
Refactor stack overflow handling Currently, every platform must implement a `Guard` that protects a thread from stack overflow. However, UNIX is the only platform that actually does so. Windows has a different mechanism for detecting stack overflow, while the other platforms don't detect it at all. Also, the UNIX stack overflow handling is split between `sys::pal::unix::stack_overflow`, which implements the signal handler, and `sys::pal::unix::thread`, which detects/installs guard pages. This PR cleans this by getting rid of `Guard` and unifying UNIX stack overflow handling inside `stack_overflow` (commit 1). Therefore we can get rid of `sys_common::thread_info`, which stores `Guard` and the current `Thread` handle and move the `thread::current` TLS variable into `thread` (commit 2). The second commit is not strictly speaking necessary. To keep the implementation clean, I've included it here, but if it causes too much noise, I can split it out without any trouble.
2024-04-01update commentjoboet-4/+1
2024-04-01std::thread: adding get_name implementation for solaris/illumos.David Carlier-3/+11
THREAD_NAME_MAX is 32 (31 max + 1 for the null terminator).
2024-03-31Auto merge of #123299 - workingjubilee:rollup-2z8amaj, r=workingjubileebors-1/+19
Rollup of 5 pull requests Successful merges: - #123180 (Rewrite `core-no-fp-fmt-parse` test in Rust) - #123267 (std::thread: adding get_name haiku implementation.) - #123268 (warn against implementing Freeze) - #123271 (doc: describe panic conditions for SliceIndex implementations) - #123295 (add myself to compiler review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-31std::thread: adding get_name haiku implementation.David Carlier-1/+19
follow-up #123233
2024-03-31catch_panic: warn about panicking payload dropRalf Jung-0/+3
2024-03-31std: move `thread::current` TLS variable out of `thread_info`joboet-176/+29
2024-03-31std: move UNIX stack overflow guard page handling into `stack_overflow.rs`joboet-310/+287
2024-03-30std::thread: adding freebsd/netbsd to the linux's get_name implementation.David Carlier-1/+8
2024-03-29stabilize ptr.is_aligned, move ptr.is_aligned_to to a new feature gateAria Beingessner-1/+1
This is an alternative to #121920
2024-03-29Auto merge of #122975 - DianQK:simplify_ub_check, r=saethlinbors-0/+1
Eliminate `UbChecks` for non-standard libraries The purpose of this PR is to allow other passes to treat `UbChecks` as constants in MIR for optimization after #122629. r? RalfJung
2024-03-27Some wording improvementVagelis Prokopiou-2/+2
2024-03-27Eliminate `UbCheck` for non-standard librariesDianQK-0/+1
2024-03-27Auto merge of #123128 - GuillaumeGomez:rollup-3l3zu6s, r=GuillaumeGomezbors-2/+2
Rollup of 6 pull requests Successful merges: - #121843 (Implement `-L KIND=`@RUSTC_BUILTIN/...`)` - #122860 (coverage: Re-enable `UnreachablePropagation` for coverage builds) - #123021 (Make `TyCtxt::coroutine_layout` take coroutine's kind parameter) - #123024 (CFI: Enable KCFI testing of run-pass tests) - #123083 (lib: fix some unnecessary_cast clippy lint) - #123116 (rustdoc: Swap fields and variant documentations) r? `@ghost` `@rustbot` modify labels: rollup
2024-03-27Rollup merge of #123083 - klensy:clippy-me, r=workingjubileeGuillaume Gomez-2/+2
lib: fix some unnecessary_cast clippy lint Fixes few instances of `unnecessary_cast` clippy lint
2024-03-27impl get_mut_or_init and get_mut_or_try_init for OnceCell and OnceLocktison-0/+81
See also https://github.com/rust-lang/rust/issues/74465#issuecomment-1676522051 Signed-off-by: tison <wander4096@gmail.com>