about summary refs log tree commit diff
path: root/library/std/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2022-03-09New `deprecated_suggestion` feature, use in testsJacob Pratt-0/+1
2022-03-09Properly abort when thread result panics on drop.Mara Bos-5/+5
2022-03-07Reverted atomic-mut-ptr feature removal causing compilation breakSandeep Bansal-0/+1
2022-03-07Stabilize const_fn_fn_ptr_basics and const_fn_trait_boundEric Holk-2/+2
2022-03-05Implement RFC 3184 - thread local cell methods.Mara Bos-0/+1
2022-03-05Clean up the std library's #![feature]sJmPotato-23/+0
Signed-off-by: JmPotato <ghzpotato@gmail.com>
2022-03-02Re-export core::ffi types from std::ffibstrie-0/+1
2022-03-01Provide C FFI types via core::ffi, not just in stdJosh Triplett-0/+2
The ability to interoperate with C code via FFI is not limited to crates using std; this allows using these types without std. The existing types in `std::os::raw` become type aliases for the ones in `core::ffi`. This uses type aliases rather than re-exports, to allow the std types to remain stable while the core types are unstable. This also moves the currently unstable `NonZero_` variants and `c_size_t`/`c_ssize_t`/`c_ptrdiff_t` types to `core::ffi`, while leaving them unstable.
2022-02-25Switch bootstrap cfgsMark Rousskov-1/+0
2022-02-21Correctly handle miniz_oxide extern crate declarationGuillaume Gomez-0/+1
2022-02-20Rollup merge of #94122 - GuillaumeGomez:miniz-oxide-std, r=notriddleMatthias Krüger-0/+4
Fix miniz_oxide types showing up in std docs Fixes #90526. Thanks to ```````@camelid,``````` I rediscovered `doc(masked)`, allowing us to prevent `miniz_oxide` type to show up in std docs. r? ```````@notriddle```````
2022-02-20Rollup merge of #93580 - m-ou-se:stabilize-pin-static-ref, r=scottmcmMatthias Krüger-1/+0
Stabilize pin_static_ref. FCP finished here: https://github.com/rust-lang/rust/issues/78186#issuecomment-1024987221 Closes #78186
2022-02-18Fix miniz_oxide types showing up in stdGuillaume Gomez-0/+4
2022-02-18Rollup merge of #93613 - crlf0710:rename_to_async_iter, r=yaahcMatthias Krüger-3/+3
Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator` Following amendments in https://github.com/rust-lang/rfcs/pull/3208/. cc #79024 cc ``@yoshuawuyts`` ``@joshtriplett``
2022-02-13Auto merge of #91673 - ChrisDenton:path-absolute, r=Mark-Simulacrumbors-0/+1
`std::path::absolute` Implements #59117 by adding a `std::path::absolute` function that creates an absolute path without reading the filesystem. This is intended to be a drop-in replacement for [`std::fs::canonicalize`](https://doc.rust-lang.org/std/fs/fn.canonicalize.html) in cases where it isn't necessary to resolve symlinks. It can be used on paths that don't exist or where resolving symlinks is unwanted. It can also be used to avoid circumstances where `canonicalize` might otherwise fail. On Windows this is a wrapper around [`GetFullPathNameW`](https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfullpathnamew). On Unix it partially implements the POSIX [pathname resolution](https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap04.html#tag_04_13) specification, stopping just short of actually resolving symlinks.
2022-02-11Auto merge of #90271 - adamgemmell:dev/feat-detect-stabilise, r=Amanieubors-3/+4
Stabilise `is_aarch64_feature_detected!` under `simd_aarch64` feature Initial implementation, looking for feedback on the approach here. https://github.com/rust-lang/rust/issues/86941 One point I noticed was that I haven't seen different "since" versions for the same feature - does this mean that other features can't be added to to the `simd_aarch64` feature once this is in stable? If so it might need a more specific name. r? `@Amanieu`
2022-02-10Move `is_aarch64_feature_detected!` to `simd_aarch64` feature and stabiliseAdam Gemmell-3/+4
2022-02-09Stabilize cfg_target_has_atomicAmanieu d'Antras-1/+1
Closes #32976
2022-02-08`std::path::absolute`Chris Denton-0/+1
2022-02-04Stabilize pin_static_ref.Mara Bos-1/+0
2022-02-03Move `{core,std}::stream::Stream` to `{core,std}::async_iter::AsyncIterator`.Charles Lew-3/+3
2022-02-03Auto merge of #93146 - workingjubilee:use-std-simd, r=Mark-Simulacrumbors-2/+20
pub use std::simd::StdFloat; Syncs portable-simd up to commit rust-lang/portable-simd@03f6fbb21e6050da2a05b3ce8f480c020b384916, Diff: https://github.com/rust-lang/portable-simd/compare/533f0fc81ab9ba097779fcd27c8f9ea12261fef5...03f6fbb21e6050da2a05b3ce8f480c020b384916 This sync requires a little bit more legwork because it also introduces a trait into `std::simd`, so that it is no longer simply a reexport of `core::simd`. Out of simple-minded consistency and to allow more options, I replicated the pattern for the way `core::simd` is integrated in the first place, however this is not necessary if it doesn't acquire any interdependencies inside `std`: it could be a simple crate reexport. I just don't know yet if that will happen or not. To summarize other misc changes: - Shifts no longer panic, now wrap on too-large shifts (like `Simd` integers usually do!) - mask16x32 will now be many i16s, not many i32s... 🙃 - `#[must_use]` is spread around generously - Adjusts division, float min/max, and `Mask::{from,to}_array` internally to be faster - Adds the much-requested `Simd::cast::<U>` function (equivalent to `simd.to_array().map(|lane| lane as U)`)
2022-01-30Rollup merge of #92887 - pietroalbini:pa-bootstrap-update, r=Mark-SimulacrumEric Huss-11/+7
Bootstrap compiler update r? ``@Mark-Simulacrum``
2022-01-28update cfg(bootstrap)sPietro Albini-11/+7
2022-01-28Move unstable is_{arch}_feature_detected! macros to std::archAmanieu d'Antras-19/+25
2022-01-27pub use std::simd::StdFloat;Jubilee Young-2/+20
Make available the remaining float intrinsics that require runtime support from a platform's libm, and thus cannot be included in a no-deps libcore, by exposing them through a sealed trait, `std::simd::StdFloat`. We might use the trait approach a bit more in the future, or maybe not. Ideally, this trait doesn't stick around, even if so. If we don't need to intermesh it with std, it can be used as a crate, but currently that is somewhat uncertain.
2022-01-22Rollup merge of #92828 - Amanieu:unwind-abort, r=dtolnayMatthias Krüger-0/+1
Print a helpful message if unwinding aborts when it reaches a nounwind function This is implemented by routing `TerminatorKind::Abort` back through the panic handler, but with a special flag in the `PanicInfo` which indicates that the panic handler should *not* attempt to unwind the stack and should instead abort immediately. This is useful for the planned change in https://github.com/rust-lang/lang-team/issues/97 which would make `Drop` impls `nounwind` by default. ### Code ```rust #![feature(c_unwind)] fn panic() { panic!() } extern "C" fn nounwind() { panic(); } fn main() { nounwind(); } ``` ### Before ``` $ ./test thread 'main' panicked at 'explicit panic', test.rs:4:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace Illegal instruction (core dumped) ``` ### After ``` $ ./test thread 'main' panicked at 'explicit panic', test.rs:4:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace thread 'main' panicked at 'panic in a function that cannot unwind', test.rs:7:1 stack backtrace: 0: 0x556f8f86ec9b - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hdccefe11a6ac4396 1: 0x556f8f88ac6c - core::fmt::write::he152b28c41466ebb 2: 0x556f8f85d6e2 - std::io::Write::write_fmt::h0c261480ab86f3d3 3: 0x556f8f8654fa - std::panicking::default_hook::{{closure}}::h5d7346f3ff7f6c1b 4: 0x556f8f86512b - std::panicking::default_hook::hd85803a1376cac7f 5: 0x556f8f865a91 - std::panicking::rust_panic_with_hook::h4dc1c5a3036257ac 6: 0x556f8f86f079 - std::panicking::begin_panic_handler::{{closure}}::hdda1d83c7a9d34d2 7: 0x556f8f86edc4 - std::sys_common::backtrace::__rust_end_short_backtrace::h5b70ed0cce71e95f 8: 0x556f8f865592 - rust_begin_unwind 9: 0x556f8f85a764 - core::panicking::panic_no_unwind::h2606ab3d78c87899 10: 0x556f8f85b910 - test::nounwind::hade6c7ee65050347 11: 0x556f8f85b936 - test::main::hdc6e02cb36343525 12: 0x556f8f85b7e3 - core::ops::function::FnOnce::call_once::h4d02663acfc7597f 13: 0x556f8f85b739 - std::sys_common::backtrace::__rust_begin_short_backtrace::h071d40135adb0101 14: 0x556f8f85c149 - std::rt::lang_start::{{closure}}::h70dbfbf38b685e93 15: 0x556f8f85c791 - std::rt::lang_start_internal::h798f1c0268d525aa 16: 0x556f8f85c131 - std::rt::lang_start::h476a7ee0a0bb663f 17: 0x556f8f85b963 - main 18: 0x7f64c0822b25 - __libc_start_main 19: 0x556f8f85ae8e - _start 20: 0x0 - <unknown> thread panicked while panicking. aborting. Aborted (core dumped) ```
2022-01-18Rollup merge of #93016 - Amanieu:vec_spare_capacity, r=Mark-SimulacrumMatthias Krüger-1/+0
Stabilize vec_spare_capacity Closes #75017
2022-01-17Stabilize vec_spare_capacityAmanieu d'Antras-1/+0
Closes #75017
2022-01-17Auto merge of #92816 - tmiasko:rm-llvm-asm, r=Amanieubors-3/+2
Remove deprecated LLVM-style inline assembly The `llvm_asm!` was deprecated back in #87590 1.56.0, with intention to remove it once `asm!` was stabilized, which already happened in #91728 1.59.0. Now it is time to remove `llvm_asm!` to avoid continued maintenance cost. Closes #70173. Closes #92794. Closes #87612. Closes #82065. cc `@rust-lang/wg-inline-asm` r? `@Amanieu`
2022-01-17Add PanicInfo::can_unwind which indicates whether a panic handler isAmanieu d'Antras-0/+1
allowed to trigger unwinding.
2022-01-12Remove deprecated LLVM-style inline assemblyTomasz Miąsko-3/+2
2022-01-11Partially stabilize `maybe_uninit_extra`Miguel Ojeda-1/+0
This covers: impl<T> MaybeUninit<T> { pub unsafe fn assume_init_read(&self) -> T { ... } pub unsafe fn assume_init_drop(&mut self) { ... } } It does not cover the const-ness of `write` under `const_maybe_uninit_write` nor the const-ness of `assume_init_read` (this commit adds `const_maybe_uninit_assume_init_read` for that). FCP: https://github.com/rust-lang/rust/issues/63567#issuecomment-958590287. Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-01-08Make source links look cleanerJacob Hoffman-Andrews-2/+2
Change from syntaxy-looking [src] to the plain word "source".
2022-01-05Add is_riscv_feature_detected!; modify impl of hint::spin_loopluojia65-0/+1
Update library/core/src/hint.rs Co-authored-by: Amanieu d'Antras <amanieu@gmail.com> Remove redundant config gate
2021-12-15Rollup merge of #91881 - Patrick-Poitras:stabilize-iter-zip, r=scottmcmMatthias Krüger-1/+0
Stabilize `iter::zip` Hello all! As the tracking issue (#83574) for `iter::zip` completed the final commenting period without any concerns being raised, I hereby submit this stabilization PR on the issue. As the pull request that introduced the feature (#82917) states, the `iter::zip` function is a shorter way to zip two iterators. As it's generally a quality-of-life/ergonomic improvement, it has been integrated into the codebase without any trouble, and has been used in many places across the rust compiler and standard library since March without any issues. For more details, I would refer to `@cuviper's` original PR, or the [function's documentation](https://doc.rust-lang.org/std/iter/fn.zip.html).
2021-12-14Stabilize iter::zip.PFPoitras-1/+0
2021-12-14Auto merge of #91728 - Amanieu:stable_asm, r=joshtriplettbors-2/+0
Stabilize asm! and global_asm! Tracking issue: #72016 It's been almost 2 years since the original [RFC](https://github.com/rust-lang/rfcs/pull/2850) was posted and we're finally ready to stabilize this feature! The main changes in this PR are: - Removing `asm!` and `global_asm!` from the prelude as per the decision in #87228. - Stabilizing the `asm` and `global_asm` features. - Removing the unstable book pages for `asm` and `global_asm`. The contents are moved to the [reference](https://github.com/rust-lang/reference/pull/1105) and [rust by example](https://github.com/rust-lang/rust-by-example/pull/1483). - All links to these pages have been removed to satisfy the link checker. In a later PR these will be replaced with links to the reference or rust by example. - Removing the automatic suggestion for using `llvm_asm!` instead of `asm!` if you're still using the old syntax, since it doesn't work anymore with `asm!` no longer being in the prelude. This only affects code that predates the old LLVM-style `asm!` being renamed to `llvm_asm!`. - Updating `stdarch` and `compiler-builtins`. - Updating all the tests. r? `@joshtriplett`
2021-12-13Stabilize const_cstr_uncheckedKonrad Borowski-1/+0
2021-12-12Stabilize asm! and global_asm!Amanieu d'Antras-2/+0
They are also removed from the prelude as per the decision in https://github.com/rust-lang/rust/issues/87228. stdarch and compiler-builtins are updated to work with the new, stable asm! and global_asm! macros.
2021-12-09Auto merge of #81156 - DrMeepster:read_buf, r=joshtriplettbors-0/+2
Implement most of RFC 2930, providing the ReadBuf abstraction This replaces the `Initializer` abstraction for permitting reading into uninitialized buffers, closing #42788. This leaves several APIs described in the RFC out of scope for the initial implementation: * read_buf_vectored * `ReadBufs` Closes #42788, by removing the relevant APIs.
2021-12-06Implement concat_bytes!Smitty-0/+9
The tracking issue for this is #87555.
2021-12-05Rollup merge of #91355 - alexcrichton:stabilize-thread-local-const, r=m-ou-seMatthias Krüger-4/+1
std: Stabilize the `thread_local_const_init` feature This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-11-30Apply cfg-bootstrap switchMark Rousskov-7/+3
2021-11-29std: Stabilize the `thread_local_const_init` featureAlex Crichton-4/+1
This commit is intended to follow the stabilization disposition of the FCP that has now finished in #84223. This stabilizes the ability to flag thread local initializers as `const` expressions which enables the macro to generate more efficient code for accessing it, notably removing runtime checks for initialization. More information can also be found in #84223 as well as the tests where the feature usage was removed in this PR. Closes #84223
2021-11-24Rollup merge of #90420 - GuillaumeGomez:rustdoc-internals-feature, r=camelidGuillaume Gomez-2/+3
Create rustdoc_internals feature gate As suggested by ``@camelid`` [here](https://github.com/rust-lang/rust/pull/90398#issuecomment-955093851), since `doc_keyword` and `doc_primitive` aren't meant to be stabilized, we could put them behind a same feature flag. This is pretty much what it would look like (needs to update the tests too). The tracking issue is https://github.com/rust-lang/rust/issues/90418. What do you think ``@rust-lang/rustdoc`` ?
2021-11-24Create rustdoc_internals feature gateGuillaume Gomez-2/+3
2021-11-20Implement IEEE 754-2019 minimun and maximum functions for f32/f64Loïc BRANSTETT-0/+1
2021-11-13Auto merge of #89551 - jhpratt:stabilize-const_raw_ptr_deref, r=oli-obkbors-1/+2
Stabilize `const_raw_ptr_deref` for `*const T` This stabilizes dereferencing immutable raw pointers in const contexts. It does not stabilize `*mut T` dereferencing. This is behind the same feature gate as mutable references. closes https://github.com/rust-lang/rust/issues/51911
2021-11-13Auto merge of #89167 - workingjubilee:use-simd, r=MarkSimulacrumbors-0/+4
pub use core::simd; A portable abstraction over SIMD has been a major pursuit in recent years for several programming languages. In Rust, `std::arch` offers explicit SIMD acceleration via compiler intrinsics, but it does so at the cost of having to individually maintain each and every single such API, and is almost completely `unsafe` to use. `core::simd` offers safe abstractions that are resolved to the appropriate SIMD instructions by LLVM during compilation, including scalar instructions if that is all that is available. `core::simd` is enabled by the `#![portable_simd]` nightly feature tracked in https://github.com/rust-lang/rust/issues/86656 and is introduced here by pulling in the https://github.com/rust-lang/portable-simd repository as a subtree. We built the repository out-of-tree to allow faster compilation and a stochastic test suite backed by the proptest crate to verify that different targets, features, and optimizations produce the same result, so that using this library does not introduce any surprises. As these tests are technically non-deterministic, and thus can introduce overly interesting Heisenbugs if included in the rustc CI, they are visible in the commit history of the subtree but do nothing here. Some tests **are** introduced via the documentation, but these use deterministic asserts. There are multiple unsolved problems with the library at the current moment, including a want for better documentation, technical issues with LLVM scalarizing and lowering to libm, room for improvement for the APIs, and so far I have not added the necessary plumbing for allowing the more experimental or libm-dependent APIs to be used. However, I thought it would be prudent to open this for review in its current condition, as it is both usable and it is likely I am going to learn something else needs to be fixed when bors tries this out. The major types are - `core::simd::Simd<T, N>` - `core::simd::Mask<T, N>` There is also the `LaneCount` struct, which, together with the SimdElement and SupportedLaneCount traits, limit the implementation's maximum support to vectors we know will actually compile and provide supporting logic for bitmasks. I'm hoping to simplify at least some of these out of the way as the compiler and library evolve.