about summary refs log tree commit diff
path: root/library/std/src/lib.rs
AgeCommit message (Collapse)AuthorLines
2023-04-16Remove #[alloc_error_handler] from the compiler and libraryAmanieu d'Antras-1/+0
2023-04-16Report allocation errors as panicsAmanieu d'Antras-0/+1
2023-04-14Rollup merge of #110292 - scottmcm:sort-features-2, r=jyn514Yuki Okushi-7/+19
Add `tidy-alphabetical` to features in `alloc` & `std` So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often. Follow-up to #110269 cc `@jyn514`
2023-04-13Add `tidy-alphabetical` to features in `alloc` & `std`Scott McMurray-7/+19
So that people have to keep them sorted in future, rather than just sticking them on the end where they conflict more often.
2023-04-10Stabilize IsTerminalJosh Triplett-1/+0
closes: https://github.com/rust-lang/rust/issues/98070
2023-04-06Stabilize is_some_andJonas Platte-1/+0
2023-03-29Stabilize a portion of 'once_cell'Trevor Gross-1/+1
Move items not part of this stabilization to 'lazy_cell' or 'once_cell_try'
2023-03-27Rollup merge of #97506 - JohnTitor:stabilize-nonnull-slice-from-raw-parts, ↵Matthias Krüger-1/+0
r=m-ou-se,the8472 Stabilize `nonnull_slice_from_raw_parts` FCP is done: https://github.com/rust-lang/rust/issues/71941#issuecomment-1100910416 Note that this doesn't const-stabilize `NonNull::slice_from_raw_parts` as `slice_from_raw_parts_mut` isn't const-stabilized yet. Given #67456 and #57349, it's not likely available soon, meanwhile, stabilizing only the feature makes some sense, I think. Closes #71941
2023-03-13Rollup merge of #108419 - tgross35:atomic-as-ptr, r=m-ou-seMatthias Krüger-1/+0
Stabilize `atomic_as_ptr` Fixes #66893 This stabilizes the `as_ptr` methods for atomics. The stabilization feature gate used here is `atomic_as_ptr` which supersedes `atomic_mut_ptr` to match the change in https://github.com/rust-lang/rust/pull/107736. This needs FCP. New stable API: ```rust impl AtomicBool { pub const fn as_ptr(&self) -> *mut bool; } impl AtomicI32 { pub const fn as_ptr(&self) -> *mut i32; } // Includes all other atomic types impl<T> AtomicPtr<T> { pub const fn as_ptr(&self) -> *mut *mut T; } ``` r? libs-api ``@rustbot`` label +needs-fcp
2023-03-07Auto merge of #95317 - Jules-Bertholet:round_ties_to_even, ↵bors-0/+1
r=pnkfelix,m-ou-se,scottmcm Add `round_ties_even` to `f32` and `f64` Tracking issue: #96710 Redux of #82273. See also #55107 Adds a new method, `round_ties_even`, to `f32` and `f64`, that rounds the float to the nearest integer , rounding halfway cases to the number with an even least significant bit. Uses the `roundeven` LLVM intrinsic to do this. Of the five IEEE 754 rounding modes, this is the only one that doesn't already have a round-to-integer function exposed by Rust (others are `round`, `floor`, `ceil`, and `trunc`). Ties-to-even is also the rounding mode used for int-to-float and float-to-float `as` casts, as well as float arithmentic operations. So not having an explicit rounding method for it seems like an oversight. Bikeshed: this PR currently uses `round_ties_even` for the name of the method. But maybe `round_ties_to_even` is better, or `round_even`, or `round_to_even`?
2023-02-27Rollup merge of #107110 - strega-nil:mbtwc-wctmb, r=ChrisDentonMatthias Krüger-0/+1
[stdio][windows] Use MBTWC and WCTMB `MultiByteToWideChar` and `WideCharToMultiByte` are extremely well optimized, and therefore should probably be used when we know we can (specifically in the Windows stdio stuff). Fixes #107092
2023-02-26Move IpAddr and SocketAddr to coreLinus Färnstrand-0/+2
2023-02-25[stdio][windows] Use MBTWC and WCTMBNicole Mazzuca-0/+1
2023-02-23Stabilize atomic_as_ptrTrevor Gross-1/+0
2023-02-10Remove a couple of `#[doc(hidden)] pub fn` and their `#[feature]` gatesTobias Bucher-4/+0
2023-02-01Stabilize feature 'cstr_from_bytes_until_nul'Trevor Gross-1/+0
2023-01-25Stabilize the const_socketaddr featureLinus Färnstrand-1/+0
2023-01-17refactor[std]: do not use box syntaxjoboet-1/+0
2023-01-08Auto merge of #104658 - thomcc:rand-update-and-usable-no_std, r=Mark-Simulacrumbors-0/+27
Update `rand` in the stdlib tests, and remove the `getrandom` feature from it. The main goal is actually removing `getrandom`, so that eventually we can allow running the stdlib test suite on tier3 targets which don't have `getrandom` support. Currently those targets can only run the subset of stdlib tests that exist in uitests, and (generally speaking), we prefer not to test libstd functionality in uitests, which came up recently in https://github.com/rust-lang/rust/pull/104095 and https://github.com/rust-lang/rust/pull/104185. Additionally, the fact that we can't update `rand`/`getrandom` means we're stuck with the old set of tier3 targets, so can't test new ones. ~~Anyway, I haven't checked that this actually does allow use on tier3 targets (I think it does not, as some work is needed in stdlib submodules) but it moves us slightly closer to this, and seems to allow at least finally updating our `rand` dep, which definitely improves the status quo.~~ Checked and works now. For the most part, our tests and benchmarks are fine using hard-coded seeds. A couple tests seem to fail with this (stuff manipulating the environment expecting no collisions, for example), or become pointless (all inputs to a function become equivalent). In these cases I've done a (gross) dance (ab)using `RandomState` and `Location::caller()` for some extra "entropy". Trying to share that code seems *way* more painful than it's worth given that the duplication is a 7-line function, even if the lines are quite gross. (Keeping in mind that sharing it would require adding `rand` as a non-dev dep to std, and exposing a type from it publicly, all of which sounds truly awful, even if done behind a perma-unstable feature). See also some previous attempts: - https://github.com/rust-lang/rust/pull/86963 (in particular https://github.com/rust-lang/rust/pull/86963#issuecomment-885438936 which explains why this is non-trivial) - https://github.com/rust-lang/rust/pull/89131 - https://github.com/rust-lang/rust/pull/96626#issuecomment-1114562857 (I tried in that PR at the same time, but settled for just removing the usage of `thread_rng()` from the benchmarks, since that was the main goal). - https://github.com/rust-lang/rust/pull/104185 - Probably more. It's very tempting of a thing to "just update". r? `@Mark-Simulacrum`
2023-01-04Update rand in the stdlib tests, and remove the getrandom feature from itThom Chiovoloni-0/+27
2023-01-04docs: fix broken link "search bar"Michael Howell-1/+1
2022-12-30Replace libstd, libcore, liballoc in line comments.jonathanCogan-4/+4
2022-12-11Remove some `cfg(not(bootstrap))`Jules Bertholet-1/+1
2022-12-11Add `round_ties_even` to `f32` and `f64`Jules Bertholet-0/+1
2022-11-22Rollup merge of #104647 - RalfJung:alloc-strict-provenance, r=thomccManish Goregaokar-1/+2
enable fuzzy_provenance_casts lint in liballoc and libstd r? ````@thomcc````
2022-11-20enable fuzzy_provenance_casts lint in libstdRalf Jung-1/+2
2022-11-20Add get_many_mut methods to sliceMarvin Löbel-0/+1
2022-11-08Test const `Hash`, fix nitsonestacked-1/+1
2022-11-06Made `Sip` const `Hasher`onestacked-0/+1
2022-10-15Stabilize `duration_checked_float`Ryan Lopopolo-1/+0
Tracking issue: - https://github.com/rust-lang/rust/issues/83400
2022-10-15Add `IsTerminal` trait to determine if a descriptor or handle is a terminalJosh Triplett-0/+1
The UNIX and WASI implementations use `isatty`. The Windows implementation uses the same logic the `atty` crate uses, including the hack needed to detect msys terminals. Implement this trait for `File` and for `Stdin`/`Stdout`/`Stderr` and their locked counterparts on all platforms. On UNIX and WASI, implement it for `BorrowedFd`/`OwnedFd`. On Windows, implement it for `BorrowedHandle`/`OwnedHandle`. Based on https://github.com/rust-lang/rust/pull/91121 Co-authored-by: Matt Wilkinson <mattwilki17@gmail.com>
2022-10-08Remove empty core::lazy and std::lazyest31-3/+0
PR #98165 with commits 7c360dc117d554a11f7193505da0835c4b890c6f and c1a2db3372a4d6896744919284f3287650a38ab7 has moved all of the components of these modules into different places, namely {std,core}::sync and {std,core}::cell. The empty modules remained. As they are unstable, we can simply remove them.
2022-10-04Rollup merge of #102574 - aDotInTheVoid:const_collections_with_hasher, ↵Michael Howell-0/+1
r=oli-obk,fee1-dead Make Hash{Set,Map}::with_hasher unstably const Makes [`HashMap::with_hasher`](https://doc.rust-lang.org/stable/std/collections/hash_map/struct.HashMap.html#method.with_hasher) and [`HashSet::with_hasher`](https://doc.rust-lang.org/stable/std/collections/hash_set/struct.HashSet.html#method.with_hasher) `const`. This allows ```rust static GlobalState: Mutex<HashMap<i32, i32, SomeHasher>> = Mutex::new(HashMap::with_hasher(SomeHasher::new())) ``` Tracking issue: #102575
2022-10-02Auto merge of #98354 - camsteffen:is-some-and-by-value, r=m-ou-sebors-1/+1
Change `is_some_and` to take by value Consistent with other function-accepting `Option` methods. Tracking issue: #93050 r? `@m-ou-se`
2022-10-02Make Hash{Set,Map}::with_hasher unstably constNixon Enraght-Moony-0/+1
2022-10-01Change feature name to is_some_andCameron Steffen-1/+1
2022-10-01Error instead of panicking when setting file times if the passed ↵beetrees-0/+1
`SystemTime` doesn't fit into the required type
2022-09-29Stabilize `nonnull_slice_from_raw_parts`Yuki Okushi-1/+0
2022-09-28Rollup merge of #102232 - Urgau:stabilize-bench_black_box, r=TaKO8KiYuki Okushi-1/+0
Stabilize bench_black_box This PR stabilize `feature(bench_black_box)`. ```rust pub fn black_box<T>(dummy: T) -> T; ``` The FCP was completed in https://github.com/rust-lang/rust/issues/64102. `@rustbot` label +T-libs-api -T-libs
2022-09-27Rollup merge of #101555 - jhpratt:stabilize-mixed_integer_ops, r=joshtriplettMatthias Krüger-1/+0
Stabilize `#![feature(mixed_integer_ops)]` Tracked and FCP completed in #87840. ````@rustbot```` label +T-libs-api +S-waiting-on-review +relnotes r? rust-lang/t-libs-api
2022-09-27Stabilize bench_black_boxUrgau-1/+0
2022-09-26remove cfg(bootstrap)Pietro Albini-5/+3
2022-09-23Fix a typo in `std`'s root docsinquisitivecrystal-2/+2
2022-09-19Rollup merge of #101798 - y86-dev:const_waker, r=lcnrMatthias Krüger-0/+1
Make `from_waker`, `waker` and `from_raw` unstably `const` Make - `Context::from_waker` - `Context::waker` - `Waker::from_raw` `const`. Also added a small test.
2022-09-15Only enable the let_else feature on bootstrapest31-1/+1
On later stages, the feature is already stable. Result of running: rg -l "feature.let_else" compiler/ src/librustdoc/ library/ | xargs sed -s -i "s#\\[feature.let_else#\\[cfg_attr\\(bootstrap, feature\\(let_else\\)#"
2022-09-14Made from_waker, waker, from_raw consty86-dev-0/+1
2022-09-07Stabilize `#![feature(mixed_integer_ops)]`Jacob Pratt-1/+0
2022-08-30Auto merge of #100812 - Nilstrieb:revert-let-chains-nightly, r=Mark-Simulacrumbors-0/+1
Revert let_chains stabilization This is the revert against master, the beta revert was already done in #100538. Bumps the stage0 compiler which already has it reverted.
2022-08-29Revert let_chains stabilizationNilstrieb-0/+1
This reverts commit 326646074940222d602f3683d0559088690830f4. This is the revert against master, the beta revert was already done in #100538.
2022-08-29Rollup merge of #100819 - WaffleLapkin:use_ptr_byte_methods, r=scottmcmDylan DPC-0/+1
Make use of `[wrapping_]byte_{add,sub}` These new methods trivially replace old `.cast().wrapping_offset().cast()` & similar code. Note that [`arith_offset`](https://doc.rust-lang.org/std/intrinsics/fn.arith_offset.html) and `wrapping_offset` are the same thing. r? ``@scottmcm`` _split off from #100746_