about summary refs log tree commit diff
path: root/library/std/src
AgeCommit message (Collapse)AuthorLines
2022-04-02Create 2024 editionJacob Pratt-0/+15
2022-04-02Rollup merge of #95557 - niluxv:issue-95533, r=dtolnayDylan DPC-8/+8
Fix `thread_local!` macro to be compatible with `no_implicit_prelude` Fixes issue #95533.
2022-04-02Rollup merge of #95354 - dtolnay:rustc_const_stable, r=lcnrDylan DPC-23/+23
Handle rustc_const_stable attribute in library feature collector The library feature collector in [compiler/rustc_passes/src/lib_features.rs](https://github.com/rust-lang/rust/blob/551b4fa395fa588d91cbecfb0cdfe1baa02670cf/compiler/rustc_passes/src/lib_features.rs) has only been looking at `#[stable(…)]`, `#[unstable(…)]`, and `#[rustc_const_unstable(…)]` attributes, while ignoring `#[rustc_const_stable(…)]`. The consequences of this were: - When any const feature got stabilized (changing one or more `rustc_const_unstable` to `rustc_const_stable`), users who had previously enabled that unstable feature using `#![feature(…)]` would get told "unknown feature", rather than rustc's nicer "the feature … has been stable since … and no longer requires an attribute to enable". This can be seen in the way that https://github.com/rust-lang/rust/pull/93957#issuecomment-1079794660 failed after rebase: ```console error[E0635]: unknown feature `const_ptr_offset` --> $DIR/offset_from_ub.rs:1:35 | LL | #![feature(const_ptr_offset_from, const_ptr_offset)] | ^^^^^^^^^^^^^^^^ ``` - We weren't enforcing that a particular feature is either stable everywhere or unstable everywhere, and that a feature that has been stabilized has the same stabilization version everywhere, both of which we enforce for the other stability attributes. This PR updates the library feature collector to handle `rustc_const_stable`, and fixes places in the standard library and test suite where `rustc_const_stable` was being used in a way that does not meet the rules for a stability attribute.
2022-04-01Use MaybeUninit for clock_gettime's timespec.Mara Bos-3/+4
2022-04-01Don't spin on contended mutexes.Mara Bos-1/+3
2022-04-01Shuffle around #[inline] and #[cold] in mutex impl.Mara Bos-5/+7
2022-04-01Add comment about futex_wait timeout.Mara Bos-0/+2
2022-04-01Fix `thread_local!` macro to be compatible with `no_implicit_prelude`niluxv-8/+8
Fixes issue #95533
2022-04-01Remove need for associated_type_bounds in std.Mara Bos-3/+4
2022-04-01Rollup merge of #95032 - m-ou-se:std-features, r=yaahcMatthias Krüger-63/+74
Clean up, categorize and sort unstable features in std.
2022-03-31Adjust feature names that disagree on const stabilization versionDavid Tolnay-23/+23
2022-03-31Categorize and sort unstable features in std.Mara Bos-63/+74
2022-03-31Rollup merge of #95505 - sunfishcode:sunfishcode/fix-openbsd, r=dtolnayDylan DPC-1/+1
Fix library/std compilation on openbsd. Fix a minor typo from #95241 which prevented compilation on x86_64-unknown-openbsd.
2022-03-31match std f32 primitive docs to core f32 primitive docsPyry Kontio-2/+3
2022-03-31Rollup merge of #95130 - workingjubilee:stably-finished, r=m-ou-seDylan DPC-2/+1
Stabilize thread::is_finished Closes #90470. r? `@m-ou-se`
2022-03-30Remove antipattern from process::exit docsNoa-28/+13
2022-03-30Add ExitCode::exit_process()Noa-0/+20
2022-03-31Improve wording of "NaN as a special value" top level explanationPyry Kontio-4/+5
2022-03-30Fix library/std compilation on openbsd.Dan Gohman-1/+1
Fix a minor typo from #95241 which prevented compilation on x86_64-unknown-openbsd.
2022-03-31Improve floating point documentation:Pyry Kontio-26/+44
- Refine the "NaN as a special value" top level explanation of f32 - Refine `const NAN` docstring. - Refine `fn is_sign_positive` and `fn is_sign_negative` docstrings. - Refine `fn min` and `fn max` docstrings. - Refine `fn trunc` docstrings. - Refine `fn powi` docstrings. - Refine `fn copysign` docstrings. - Reword `NaN` and `NAN` as plain "NaN", unless they refer to the specific `const NAN`. - Reword "a number" to `self` in function docstrings to clarify. - Remove "Returns NAN if the number is NAN" as this is told to be the default behavior in the top explanation. - Remove "propagating NaNs", as full propagation (preservation of payloads) is not guaranteed.
2022-03-30Auto merge of #94963 - lcnr:inherent-impls-std, r=oli-obk,m-ou-sebors-2/+81
allow arbitrary inherent impls for builtin types in core Part of https://github.com/rust-lang/compiler-team/issues/487. Slightly adjusted after some talks with `@m-ou-se` about the requirements of `t-libs-api`. This adds a crate attribute `#![rustc_coherence_is_core]` which allows arbitrary impls for builtin types in core. For other library crates impls for builtin types should be avoided if possible. We do have to allow the existing stable impls however. To prevent us from accidentally adding more of these in the future, there is a second attribute `#[rustc_allow_incoherent_impl]` which has to be added to **all impl items**. This only supports impls for builtin types but can easily be extended to additional types in a future PR. This implementation does not check for overlaps in these impls. Perfectly checking that requires us to check the coherence of these incoherent impls in every crate, as two distinct dependencies may add overlapping methods. It should be easy enough to detect if it goes wrong and the attribute is only intended for use inside of std. The first two commits are mostly unrelated cleanups.
2022-03-30Don't stabilize ScopedJoinHandle::is_finished yet.Mara Bos-1/+0
2022-03-30Synchronize asynchronous pipe reads and writesChris Denton-2/+138
2022-03-30Auto merge of #95241 - Gankra:cleaned-provenance, r=workingjubileebors-82/+101
Strict Provenance MVP This patch series examines the question: how bad would it be if we adopted an extremely strict pointer provenance model that completely banished all int<->ptr casts. The key insight to making this approach even *vaguely* pallatable is the ptr.with_addr(addr) -> ptr function, which takes a pointer and an address and creates a new pointer with that address and the provenance of the input pointer. In this way the "chain of custody" is completely and dynamically restored, making the model suitable even for dynamic checkers like CHERI and Miri. This is not a formal model, but lots of the docs discussing the model have been updated to try to the *concept* of this design in the hopes that it can be iterated on. See #95228
2022-03-30remove now unnecessary lang itemslcnr-2/+2
2022-03-30rework implementation for inherent impls for builtin typeslcnr-0/+79
2022-03-30Rollup merge of #95452 - yaahc:termination-version-correction, r=ehussDylan DPC-13/+13
fix since field version for termination stabilization fixes incorrect version fields in stabilization of https://github.com/rust-lang/rust/pull/93840 r? `@ehuss`
2022-03-30Rollup merge of #95294 - sourcefrog:doc-copy, r=dtolnayDylan DPC-3/+19
Document Linux kernel handoff in std::io::copy and std::fs::copy
2022-03-29Warn that platform-specific behavior may changeMartin Pool-1/+5
2022-03-29fix unix typedefAria Beingessner-1/+1
2022-03-29mark FIXMES for all the places found that are probably offset_fromAria Beingessner-0/+2
2022-03-29cleanup some of the less terrifying library codeAria Beingessner-1/+1
2022-03-29revert changes that cast functions to raw pointers, portability hazardAria Beingessner-11/+10
2022-03-29Make some linux/unix APIs better conform to strict provenance.Alexis Beingessner-36/+39
This largely makes the stdlib conform to strict provenance on Ubuntu. Some hairier things have been left alone for now.
2022-03-29Make the stdlib largely conform to strict provenance.Aria Beingessner-57/+72
Some things like the unwinders and system APIs are not fully conformant, this only covers a lot of low-hanging fruit.
2022-03-29fix since field version for termination stabilizationJane Lusby-13/+13
2022-03-29Rollup merge of #95256 - thomcc:fix-unwind-safe, r=m-ou-seDylan DPC-5/+15
Ensure io::Error's bitpacked repr doesn't accidentally impl UnwindSafe Sadly, I'm not sure how to easily test that we don't impl a trait, though (or can libstd use `where io::Error: !UnwindSafe` or something). Fixes #95203
2022-03-29Rollup merge of #93840 - ↵Dylan DPC-24/+68
yaahc:termination-stabilization-celebration-station, r=joshtriplett Stabilize Termination and ExitCode From https://github.com/rust-lang/rust/issues/43301 This PR stabilizes the Termination trait and associated ExitCode type. It also adjusts the ExitCode feature flag to replace the placeholder flag with a more permanent name, as well as splitting off the `to_i32` method behind its own permanently unstable feature flag. This PR stabilizes the termination trait with the following signature: ```rust pub trait Termination { fn report(self) -> ExitCode; } ``` The existing impls of `Termination` are effectively already stable due to the prior stabilization of `?` in main. This PR also stabilizes the following APIs on exit code ```rust #[derive(Clone, Copy, Debug)] pub struct ExitCode(_); impl ExitCode { pub const SUCCESS: ExitCode; pub const FAILURE: ExitCode; } impl From<u8> for ExitCode { /* ... */ } ``` --- All of the previous blockers have been resolved. The main ones that were resolved recently are: * The trait's name: We decided against changing this since none of the alternatives seemed particularly compelling. Instead we decided to end the bikeshedding and stick with the current name. ([link to the discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Termination.2FExit.20Status.20Stabilization/near/269793887)) * Issues around platform specific representations: We resolved this issue by changing the return type of `report` from `i32` to the opaque type `ExitCode`. That way we can change the underlying representation without affecting the API, letting us offer full support for platform specific exit code APIs in the future. * Custom exit codes: We resolved this by adding `From<u8> for ExitCode`. We choose to only support u8 initially because it is the least common denominator between the sets of exit codes supported by our current platforms. In the future we anticipate adding platform specific extension traits to ExitCode for constructors from larger or negative numbers, as needed.
2022-03-29Indicate the correct error code in the `compile_fail` block.Thom Chiovoloni-1/+1
Co-authored-by: Mara Bos <m-ou.se@m-ou.se>
2022-03-29Auto merge of #95375 - MarcusCalhoun-Lopez:i686_apple_darwin, r=m-ou-sebors-5/+8
Fix build on i686-apple-darwin systems Replace `target_arch = "x86_64"` with `not(target_arch = "aarch64")` so that i686-apple-darwin systems dynamically choose implementation.
2022-03-28Fix build on i686-apple-darwin systemsMarcus Calhoun-Lopez-0/+3
On 32-bit systems, fdopendir is called `_fdopendir$INODE64$UNIX2003`. On 64-bit systems, fdopendir is called `_fdopendir$INODE64`.
2022-03-28Fix build on i686-apple-darwin systemsMarcus Calhoun-Lopez-5/+5
Replace `target_arch = "x86_64"` with `not(target_arch = "aarch64")` so that i686-apple-darwin systems dynamically choose implementation.
2022-03-28Touch up ExitCode docsNoa-7/+26
2022-03-27Link to std::io's platform-specific behavior disclaimerDavid Tolnay-4/+13
2022-03-25Check for `"` and `\` in a filenameChris Denton-1/+9
And also fix typo.
2022-03-25std::process docs: linkify references to output, spawn and statusest31-7/+20
2022-03-24Document Linux kernel handoff in std::io::copy and std::fs::copyMartin Pool-2/+14
2022-03-24Explicitly use CLOCK_MONOTONIC in futex_wait.Mara Bos-3/+3
Instant might be changed to use CLOCK_BOOTTIME at some point.
2022-03-24Make Timespec available in sys::unix.Mara Bos-15/+13
2022-03-24Use FUTEX_WAIT_BITSET rather than FUTEX_WAIT on Linux.Mara Bos-22/+38