about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2023-09-26std: broaden the allowed behaviour for recursive TLS initializationjoboet-3/+3
2023-09-25Auto merge of #116070 - eduardosm:IoSlice-advance_slices-checked_add, ↵bors-16/+19
r=Mark-Simulacrum Avoid overflow in `IoSlice::advance_slices` Noticed in https://github.com/rust-lang/rust/issues/62726#issuecomment-1713997431.
2023-09-25Document that Instant may or may not include system-suspend timeThe 8472-0/+2
2023-09-25update other placeMilo-1/+1
2023-09-25clarify documentation about variable substituionMilo-1/+1
2023-09-25Auto merge of #116057 - RalfJung:io-safety, r=Mark-Simulacrumbors-8/+14
fix OS-specific I/O safety docs since the io_safety feature is stable Looks like this text was forgotten to be updated when `io_safety` got stabilized: it still says "once the io_safety feature is stable". Also adjust the wording a bit for how these docs relate to the general concept of I/O safety.
2023-09-24Auto merge of #105861 - Ayush1325:uefi-std-minimial, r=workingjubileebors-5/+822
Add Minimal Std implementation for UEFI # Implemented modules: 1. alloc 2. os_str 3. env 4. math # Related Links Tracking Issue: https://github.com/rust-lang/rust/issues/100499 API Change Proposal: https://github.com/rust-lang/libs-team/issues/87 # Additional Information This was originally part of https://github.com/rust-lang/rust/pull/100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from `@dvdhrm,` I have extracted a minimal std implementation to this PR. The example in `src/doc/rustc/src/platform-support/unknown-uefi.md` has been tested for `x86_64-unknown-uefi` and `i686-unknown-uefi` in OVMF. It would be great if someone more familiar with AARCH64 can help with testing for that target. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-24Auto merge of #115416 - c410-f3r:match_cfg, r=Amanieubors-0/+3
Add the `cfg_match!` macro # Movitation Adds a match-like version of the `cfg_if` crate without a RFC [for the same reasons that caused `matches!` to be included in the standard library](https://github.com/rust-lang/rust/pull/65479). * General-purpose (not domain-specific) * Simple (the implementation is short) and useful (things can become difficult with several `cfg`s) * Very popular [on crates.io ](https://crates.io/crates/cfg-if) (currently 3th in all-time downloads) * The two previous points combined make it number three in [left-pad index](https://twitter.com/bascule/status/1184523027888988160) score ```rust match_cfg! { cfg(unix) => { fn foo() { /* unix specific functionality */ } } cfg(target_pointer_width = "32") => { fn foo() { /* non-unix, 32-bit functionality */ } } _ => { fn foo() { /* fallback implementation */ } } } ``` # Considerations A match-like syntax feels more natural in the sense that each macro fragment resembles an arm but I personally don't mind switching to any other desired syntax. The lack of `#[ ... ]` is intended to reduce typing, nevertheless, the same reasoning described above can also be applied to this aspect. Since blocks are intended to only contain items, anything but `cfg` is not expected to be supported at the current or future time. ~~Credits goes to `@gnzlbg` because most of the code was shamelessly copied from https://github.com/gnzlbg/match_cfg.~~ Credits goes to `@alexcrichton` because most of the code was shamelessly copied from https://github.com/rust-lang/cfg-if.
2023-09-24Auto merge of #104385 - BlackHoleFox:apple-minimum-bumps, r=petrochenkovbors-3/+2
Raise minimum supported Apple OS versions This implements the proposal to raise the minimum supported Apple OS versions as laid out in the now-completed MCP (https://github.com/rust-lang/compiler-team/issues/556). As of this PR, rustc and the stdlib now support these versions as the baseline: - macOS: 10.12 Sierra - iOS: 10 - tvOS: 10 - watchOS: 5 (Unchanged) In addition to everything this breaks indirectly, these changes also erase the `armv7-apple-ios` target (currently tier 3) because the oldest supported iOS device now uses ARMv7s. Not sure what the policy around tier3 target removal is but shimming it is not an option due to the linker refusing. [Per comment](https://github.com/rust-lang/compiler-team/issues/556#issuecomment-1297175073), this requires a FCP to merge. cc `@wesleywiser.`
2023-09-23Raise minimum supported iOS version to 10.0BlackHoleFox-1/+1
Drop the armv7-apple-ios target too because its no longer supported with the hardware iOS 10 requires.
2023-09-23Raise minimum supported macOS to 10.12BlackHoleFox-2/+1
2023-09-23Add the `cfg_match!` macroCaio-0/+3
2023-09-23Avoid overflow in `IoSlice::advance_slices`Eduardo Sánchez Muñoz-16/+19
2023-09-22Fixes from PRAyush Singh-5/+5
- Hide Docs - Use repr_unpacked error Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-09-22Rebase to masterAyush Singh-48/+100
- Update Example - Add thread_parking to sys::uefi - Fix unsafe in unsafe errors - Improve docs - Improve os/exit - Some asserts - Switch back to atomics Signed-off-by: Ayush Singh <ayushdevel1325@gmail.com>
2023-09-22Use RawOsError for UEFIAyush Singh-178/+261
Some changes from this commit will probably be converted to its own PR. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Fixes from PRAyush Singh-5/+7
- Some comment fixes. - Make some functions unsafe. - Make helpers module private. - Rebase on master - Update r-efi to v4.2.0 Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Add support for building `std::os::uefi` docsAyush Singh-28/+33
Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Handle ExitBootServicesAyush Singh-26/+116
- Make BootServices unavailable if ExitBootServices event is signaled. - Use thread locals for SystemTable and ImageHandle Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Fixes from PRAyush Singh-39/+46
Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22Add Minimal Std implementation for UEFIAyush Singh-2/+580
Implemented modules: 1. alloc 2. os_str 3. env 4. math Tracking Issue: https://github.com/rust-lang/rust/issues/100499 API Change Proposal: https://github.com/rust-lang/libs-team/issues/87 This was originally part of https://github.com/rust-lang/rust/pull/100316. Since that PR was becoming too unwieldy and cluttered, and with suggestion from @dvdhrm, I have extracted a minimal std implementation to this PR. Signed-off-by: Ayush Singh <ayushsingh1325@gmail.com>
2023-09-22fix OS-specific I/O safety docs since the io_safety feature is stableRalf Jung-8/+14
2023-09-22Auto merge of #116054 - matthiaskrgr:rollup-3pusno6, r=matthiaskrgrbors-8/+87
Rollup of 7 pull requests Successful merges: - #114379 (Command: also print removed env vars) - #116034 (add UI test for delimiter errors) - #116036 (tests/ui: Split large_moves.rs and move to lint/large_assignments) - #116038 (Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty mask) - #116039 (Account for nested `impl Trait` in TAIT) - #116041 (Add note to `is_known_rigid`) - #116049 (give FutureIncompatibilityReason variants more explicit names) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-22Rollup merge of #116038 - the8472:panic-on-sched_getaffinity-bug, r=cuviperMatthias Krüger-6/+19
Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty mask Followup to #115946 A gentler fix for #115868, one that doesn't panic, [suggested on zulip](https://rust-lang.zulipchat.com/#narrow/stream/259402-t-libs.2Fmeetings/topic/Meeting.202023-09-19/near/391942927) In that situation - on the buggy kernel versions - a zero-mask means no affinities have been set so `_SC_NPROCESSORS_ONLN` provides the right value.
2023-09-22Rollup merge of #114379 - RalfJung:command-removed-env-vars, r=m-ou-seMatthias Krüger-2/+68
Command: also print removed env vars There is no real shell syntax for unsetting an env var so easily, so we have to make one up. But we already do that for showing the 'program' name so I hope that's okay here, too. No strong opinion on what that should look like, I went with `unset(VAR_NAME)` for now.
2023-09-22Auto merge of #114780 - RalfJung:io-safety, r=Amanieubors-29/+99
add more explicit I/O safety documentation Fixes https://github.com/rust-lang/unsafe-code-guidelines/issues/434 Cc https://github.com/rust-lang/rust/issues/114167 Cc `@Manishearth` `@sunfishcode` `@joshtriplett`
2023-09-21Auto merge of #115230 - Vtewari2311:mod-hurd-latest, r=b-naberbors-27/+511
added support for GNU/Hurd adding support for i686-unknown-hurd-gnu
2023-09-21Fall back to _SC_NPROCESSORS_ONLN if sched_getaffinity returns an empty maskThe 8472-6/+19
2023-09-21added support for GNU/HurdSamuel Thibault-27/+511
2023-09-21Auto merge of #116013 - matthiaskrgr:rollup-mv5i4fd, r=matthiaskrgrbors-21/+21
Rollup of 4 pull requests Successful merges: - #114394 (style-guide: Document formatting of `as` casts (mostly like a binary operator)) - #115990 (Allow anyone to set llvm-fixed-upstream) - #116008 (Rename BoxMeUp to PanicPayload.) - #116011 (Update browser-ui-test version to 0.16.10) r? `@ghost` `@rustbot` modify labels: rollup
2023-09-21Rollup merge of #116008 - m-ou-se:boxmeup, r=oli-obkMatthias Krüger-21/+21
Rename BoxMeUp to PanicPayload. "BoxMeUp" is not very clear. Let's rename that to a description of what it actually represents: a panic payload. This PR also renames the structs that implement this trait to have more descriptive names. Part of https://github.com/rust-lang/rust/issues/116005 r? `@oli-obk`
2023-09-20Auto merge of #115542 - saethlin:fileencoder-is-bufwriter, r=WaffleLapkinbors-0/+1
Simplify/Optimize FileEncoder FileEncoder is basically a BufWriter except that it exposes access to the not-written-to-yet region of the buffer so that some users can write directly to the buffer. This strategy is awesome because it lets us avoid calling memcpy for small copies, but the previous strategy was based on the writer accessing a `&mut [MaybeUninit<u8>; N]` and returning a `&[u8]` which is an API which currently mandates the use of unsafe code, making that interface in general not that appealing. So this PR cleans up the FileEncoder implementation and builds on that general idea of direct buffer access in order to prevent `memcpy` calls in a few key places when encoding the dep graph and rmeta tables. The interface used here is now 100% safe, but with the caveat that internally we need to avoid trusting the number of bytes that the provided function claims to have written. The original primary objective of this PR was to clean up the FileEncoder implementation so that the fix for the following issues would be easy to implement. The fix for these issues is to correctly update self.buffered even when writes fail, which I think it's easy to verify manually is now done, because all the FileEncoder methods are small. Fixes https://github.com/rust-lang/rust/issues/115298 Fixes https://github.com/rust-lang/rust/issues/114671 Fixes https://github.com/rust-lang/rust/issues/114045 Fixes https://github.com/rust-lang/rust/issues/108100 Fixes https://github.com/rust-lang/rust/issues/106787
2023-09-20PR feedbackBen Kimock-0/+1
2023-09-20Rename BoxMeUp to PanicPayload.Mara Bos-21/+21
2023-09-20Auto merge of #115753 - tgross35:threadinfo-refactor, r=thomccbors-16/+21
Refactor `thread_info` to remove the `RefCell` `thread_info` currently uses `RefCell`-based initialization. Refactor this to use `OnceCell` instead which is more performant and better suits the needs of one-time initialization. This is nobody's bottleneck but OnceCell checks are a single `cmp` vs. `RefCell<Option>` needing runtime logic
2023-09-19Auto merge of #115627 - compiler-errors:icedump-no-std, r=m-ou-sebors-32/+7
Don't modify libstd to dump rustc ICEs Do a much simpler thing and just dump a `std::backtrace::Backtrace` to file. r? `@estebank` `@oli-obk` Fixes #115610
2023-09-19Replace 'mutex' with 'lock' in RwLock documentationKriskras99-2/+2
When copying the documentation for `clear_poison` from Mutex, not every occurence of 'mutex' was replaced with 'lock'.
2023-09-19Rollup merge of #115946 - the8472:panic-on-sched_getaffinity-bug, ↵Guillaume Gomez-2/+4
r=Mark-Simulacrum panic when encountering an illegal cpumask in thread::available_parallelism Fixes #115868 by panicking instead of returning an invalid `NonZeroUsize`
2023-09-19Auto merge of #104101 - betrusted-io:xous-libstd-initial, r=bjorn3bors-4/+2473
Add initial libstd support for Xous This patchset adds some minimal support to the tier-3 target `riscv32imac-unknown-xous-elf`. The following features are supported: * alloc * thread creation and joining * thread sleeping * thread_local * panic_abort * mutex * condvar * stdout Additionally, internal support for the various Xous primitives surrounding IPC have been added as part of the Xous FFI. These may be exposed as part of `std::os::xous::ffi` in the future, however for now they are not public. This represents the minimum viable product. A future patchset will add support for networking and filesystem support.
2023-09-18panic when encountering an illegal cpumaskThe 8472-2/+4
2023-09-18get rid of duplicate primitive_docsRalf Jung-1594/+1
2023-09-17Rollup merge of #115477 - kellerkindt:stabilized_int_impl, r=dtolnayDylan DPC-2/+1
Stabilize the `Saturating` type Closes #87920 Closes #92354 Stabilization report https://github.com/rust-lang/rust/issues/87920#issuecomment-1652346124 FCP https://github.com/rust-lang/rust/issues/87920#issuecomment-1676438885
2023-09-17Rollup merge of #114965 - benschulz:mpsc-drop, r=dtolnayDylan DPC-15/+0
Remove Drop impl of mpsc Receiver and (Sync)Sender This change removes the empty `Drop` implementations for `mpsc::Receiver`, `mpsc::Sender` and `mpsc::SyncSender`. These implementations do not specify `#[may_dangle]`, so by removing them we make `mpsc` types play nice with drop check. This was previously attempted in [#105243](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337188646) but then [abandoned due to a test failure](https://github.com/rust-lang/rust/pull/105243#issuecomment-1337227970). I've aligned the test with those for `Mutex` and `RwLock`.
2023-09-17Auto merge of #113753 - dvdsk:master, r=dtolnaybors-1/+81
Add implementation for thread::sleep_until - Feature gate is `thread::sleep_until` - Tracking issue is: #113752 - APC: https://github.com/rust-lang/libs-team/issues/237
2023-09-16Rollup merge of #115329 - xzmeng:fix-std-doc, r=dtolnayMatthias Krüger-4/+4
fix std::primitive doc: homogenous -> homogeneous replace "homogenous" with the more commonly used "homogeneous".
2023-09-16Rollup merge of #115247 - the8472:life-before-main, r=dtolnayMatthias Krüger-1/+25
Document std limitations before/after main Solves #110708
2023-09-13Disabled socketpair for VitaNikolay Arhipov-2/+2
2023-09-11Refactor `thread_info` to remove the `RefCell`Trevor Gross-16/+21
`thread_info` currently uses `RefCell`-based initialization. Refactor this to use `OnceCell` instead which is more performant and better suits the needs of one-time initialization.
2023-09-10Auto merge of #114967 - japaric:ja-gh114966, r=Mark-Simulacrumbors-0/+4
QNX: pass a truncated thread name to the OS The maximum length the thread name can have is `_NTO_THREAD_NAME_MAX` fixes #114966
2023-09-09Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnaybors-11/+134
Allow redirecting subprocess stdout to our stderr etc. (redux) This is the code from #88561, tidied up, including review suggestions, and with the for-testing-only CI commit removed. FCP for the API completed in #88561. I have made a new MR to facilitate review. The discussion there is very cluttered and the branch is full of changes (in many cases as a result of changes to other Rust stdlib APIs since then). Assuming this MR is approvedl we should close that one. ### Reviewer doing a de novo review Just code review these four commits.. FCP discussion starts here: https://github.com/rust-lang/rust/pull/88561#issuecomment-1640527595 Portability tests: you can see that this branch works on Windows too by looking at the CI results in #88561, which has the same code changes as this branch but with an additional "DO NOT MERGE" commit to make the Windows tests run. ### Reviewer doing an incremental review from some version of #88561 Review the new commits since your last review. I haven't force pushed the branch there. git diff the two branches (eg `git diff 176886197d6..0842b69c219`). You'll see that the only difference is in gitlab CI files. You can also see that *this* MR doesn't touch those files.