about summary refs log tree commit diff
path: root/library/core/tests
AgeCommit message (Collapse)AuthorLines
2024-09-20Auto merge of #124895 - obeis:static-mut-hidden-ref, r=compiler-errorsbors-0/+2
Disallow hidden references to mutable static Closes #123060 Tracking: - https://github.com/rust-lang/rust/issues/123758
2024-09-19Rollup merge of #128001 - Krappa322:master, r=scottmcmMatthias Krüger-0/+2
Improve documentation for <integer>::from_str_radix Two improvements to the documentation: - Document `-` as a valid character for signed integer destinations - Make the documentation even more clear that extra whitespace and non-digit characters is invalid. Many other languages, e.g. c++, are very permissive in string to integer routines and simply try to consume as much as they can, ignoring the rest. This is trying to make the transition for developers who are used to the conversion semantics in these languages a bit easier.
2024-09-18remove feature attributes as const_maybe_uninit_as_mut_ptr is stabilizedultrabear-1/+0
2024-09-18Rollup merge of #130476 - workingjubilee:more-lazy-methods-take-2, r=AmanieuJubilee-0/+22
Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut` Tracking issue for `lazy_get`: https://github.com/rust-lang/rust/issues/129333
2024-09-18library: Destabilize Lazy{Cell,Lock}::{force,deref}_mutJubilee Young-0/+1
2024-09-17Implement ACP 429: add `Lazy{Cell,Lock}::get[_mut]` and `force_mut`Chayim Refael Friedman-0/+21
In the implementation of `force_mut`, I chose performance over safety. For `LazyLock` this isn't really a choice; the code has to be unsafe. But for `LazyCell`, we can have a full-safe implementation, but it will be a bit less performant, so I went with the unsafe approach.
2024-09-17Auto merge of #130145 - fee1-dead-contrib:repeatn, r=lcnr,workingjubileebors-0/+24
`RepeatN`: use MaybeUninit Closes #130140. Closes #130141. Use `MaybeUninit` instead of `ManuallyDrop` for soundness.
2024-09-15stabilize const_mut_refsRalf Jung-1/+1
2024-09-13RustfmtCaio-1/+1
2024-09-13[`cfg_match`] Generalize inputsCaio-0/+20
2024-09-13Update tests for hidden references to mutable staticObei Sideg-0/+2
2024-09-12Rollup merge of #130101 - RalfJung:const-cleanup, r=fee1-deadMatthias Krüger-5/+2
some const cleanup: remove unnecessary attributes, add const-hack indications I learned that we use `FIXME(const-hack)` on top of the "const-hack" label. That seems much better since it marks the right place in the code and moves around with the code. So I went through the PRs with that label and added appropriate FIXMEs in the code. IMO this means we can then remove the label -- Cc ``@rust-lang/wg-const-eval.`` I also noticed some const stability attributes that don't do anything useful, and removed them. r? ``@fee1-dead``
2024-09-09fix UB in a testRalf Jung-1/+6
also add an explicit test for the fact that a Option<WidePtr> has padding when it is None
2024-09-09`RepeatN`: use MaybeUninitDeadbeef-0/+24
2024-09-08add FIXME(const-hack)Ralf Jung-5/+2
2024-09-07Auto merge of #129941 - BoxyUwU:bump-boostrap, r=albertlarsan68bors-1/+0
Bump boostrap compiler to new beta Accidentally left some comments on the update cfgs commit directly xd
2024-09-05update cfgsBoxy-1/+0
2024-09-02Stabilize waker_gettersKevin Mehall-1/+0
2024-09-02Move the `data` and `vtable` methods from `RawWaker` to `Waker`Kevin Mehall-6/+5
Per the `waker_getters` FCP: https://github.com/rust-lang/rust/issues/96992#issuecomment-1941998046
2024-08-31Improve documentation for <integer>::from_str_radixKappa322-0/+2
Two improvements to the documentation: - Document `-` as a valid character for signed integer destinations - Make the documentation even more clear that extra whitespace and non-digit characters is invalid. Many other languages, e.g. c++, are very permissive in string to integer routines and simply try to consume as much as they can, ignoring the rest. This is trying to make the transition for developers who are used to the conversion semantics in these languages a bit easier.
2024-08-31Rollup merge of #129640 - saethlin:unignore-android-in-alloc, r=tgross35Matthias Krüger-13/+5
Re-enable android tests/benches in alloc/core This is basically a revert of https://github.com/rust-lang/rust/pull/73729. These tests better work on android now; it's been 4 years and we don't use dlmalloc on that target anymore. And I've validated that they should pass now with a try-build :)
2024-08-28Improve `isqrt` tests and add benchmarksChai T. Rex-32/+249
* Choose test inputs more thoroughly and systematically. * Check that `isqrt` and `checked_isqrt` have equivalent results for signed types, either equivalent numerically or equivalent as a panic and a `None`. * Check that `isqrt` has numerically-equivalent results for unsigned types and their `NonZero` counterparts. * Reuse `ilog10` benchmarks, plus benchmarks that use a uniform distribution.
2024-08-28Enable some ilog2 tests as wellBen Kimock-13/+5
2024-08-25Remove cfg(test) from library/coreBen Kimock-656/+649
2024-08-22Auto merge of #129365 - matthiaskrgr:rollup-ebwx6ya, r=matthiaskrgrbors-34/+353
Rollup of 9 pull requests Successful merges: - #127279 (use old ctx if has same expand environment during decode span) - #127945 (Implement `debug_more_non_exhaustive`) - #128941 ( Improve diagnostic-related lints: `untranslatable_diagnostic` & `diagnostic_outside_of_impl`) - #129070 (Point at explicit `'static` obligations on a trait) - #129187 (bootstrap: fix clean's remove_dir_all implementation) - #129231 (improve submodule updates) - #129264 (Update `library/Cargo.toml` in weekly job) - #129284 (rustdoc: animate the `:target` highlight) - #129302 (compiletest: use `std::fs::remove_dir_all` now that it is available) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-21Rollup merge of #129321 - krtab:float_sum, r=workingjubileeMatthias Krüger-0/+28
Change neutral element of <fNN as iter::Sum> to neg_zero The neutral element used to be positive zero, but +0 + -0 = +0 so -0 seems better indicated.
2024-08-21Rollup merge of #127945 - tgross35:debug-more-non-exhaustive, r=NoratriebMatthias Krüger-34/+353
Implement `debug_more_non_exhaustive` This implements the ACP at https://github.com/rust-lang/libs-team/issues/248, adding `.finish_non_exhaustive()` for `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`. Also used this as an opportunity to make some documentation and tests more readable by using raw strings instead of escaped quotes. Tracking issue: https://github.com/rust-lang/rust/issues/127942
2024-08-20Change neutral element of <fNN as iter::Sum> to neg_zeroArthur Carcano-0/+28
The neutral element used to be positive zero, but +0 + -0 = +0 so -0 seems better indicated.
2024-08-19Stabilize `iter::repeat_n`Scott McMurray-1/+0
2024-08-17Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnaybors-0/+40
CloneToUninit impls As per #126799. Also implements it for `Wtf8` and both versions of `os_str::Slice`. Maybe it is worth to slap `#[inline]` on some of those impls. r? `@dtolnay`
2024-07-29impl CloneToUninit for str and CStrPavel Grigorenko-0/+40
2024-07-29Reformat `use` declarations.Nicholas Nethercote-50/+51
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-28Rollup merge of #128228 - slanterns:const_waker, r=dtolnay,oli-obkGuillaume Gomez-1/+32
Stabilize `const_waker` Closes: https://github.com/rust-lang/rust/issues/102012. For `local_waker` and `context_ext` related things, I just ~~moved them to dedicated feature gates and reused their own tracking issue (maybe it's better to open a new one later, but at least they should not be tracked under https://github.com/rust-lang/rust/issues/102012 from the beginning IMO.)~~ reused their own feature gates as suggested by ``@tgross35.`` ``@rustbot`` label: +T-libs-api r? libs-api
2024-07-28Rollup merge of #128103 - folkertdev:unsigned-int-is-multiple-of, r=AmanieuGuillaume Gomez-0/+9
add `is_multiple_of` for unsigned integer types tracking issue: https://github.com/rust-lang/rust/issues/128101 This adds the `.is_multiple_of` method on unsigned integers. Returns `true` if `self` is an integer multiple of `rhs`, and false otherwise. This function is equivalent to `self % rhs == 0`, except that it will not panic for `rhs == 0`. Instead, `0.is_multiple_of(0) == true`, and for any non-zero `n`, `n.is_multiple_of(0) == false`.
2024-07-28Rollup merge of #127765 - bitfield:fix_stdlib_doc_nits, r=dtolnayGuillaume Gomez-1/+1
Fix doc nits Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo"), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits.
2024-07-28stabilize const_wakerSlanterns-1/+32
2024-07-28stabilize `is_sorted`Slanterns-1/+0
2024-07-26Rollup merge of #124941 - Skgland:stabilize-const-int-from-str, r=dtolnayTrevor Gross-1/+0
Stabilize const `{integer}::from_str_radix` i.e. `const_int_from_str` This PR stabilizes the feature `const_int_from_str`. - ACP Issue: rust-lang/libs-team#74 - Implementation PR: rust-lang/rust#99322 - Part of Tracking Issue: rust-lang/rust#59133 API Change Diff: ```diff impl {integer} { - pub fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>; + pub const fn from_str_radix(src: &str, radix: u32) -> Result<Self, ParseIntError>; } impl ParseIntError { - pub fn kind(&self) -> &IntErrorKind; + pub const fn kind(&self) -> &IntErrorKind; } ``` This makes it easier to parse integers at compile-time, e.g. the example from the Tracking Issue: ```rust env!("SOMETHING").parse::<usize>().unwrap() ``` could now be achived with ```rust match usize::from_str_radix(env!("SOMETHING"), 10) { Ok(val) => val, Err(err) => panic!("Invalid value for SOMETHING environment variable."), } ``` rather than having to depend on a library that implements or manually implement the parsing at compile-time. --- Checklist based on [Libs Stabilization Guide - When there's const involved](https://std-dev-guide.rust-lang.org/development/stabilization.html#when-theres-const-involved) I am treating this as a [partial stabilization](https://std-dev-guide.rust-lang.org/development/stabilization.html#partial-stabilizations) as it shares a tracking issue (and is rather small), so directly opening the partial stabilization PR for the subset (feature `const_int_from_str`) being stabilized. - [x] ping Constant Evaluation WG - [x] no unsafe involved - [x] no `#[allow_internal_unstable]` - [ ] usage of `intrinsic::const_eval_select` rust-lang/rust#124625 in `from_str_radix_assert` to change the error message between compile-time and run-time - [ ] [rust-labg/libs-api FCP](https://github.com/rust-lang/rust/pull/124941#issuecomment-2207021921)
2024-07-26Fix doc nitsJohn Arundel-1/+1
Many tiny changes to stdlib doc comments to make them consistent (for example "Returns foo", rather than "Return foo", per RFC1574), adding missing periods, paragraph breaks, backticks for monospace style, and other minor nits. https://github.com/rust-lang/rfcs/blob/master/text/1574-more-api-documentation-conventions.md#appendix-a-full-conventions-text
2024-07-25CStr: derive PartialEq, Eq; add test for OrdPavel Grigorenko-0/+17
2024-07-23add `is_multiple_of` for unsigned integer typesFolkert-0/+9
2024-07-21Implement `debug_more_non_exhaustive`Trevor Gross-2/+321
Add a `.finish_non_exhaustive()` method to `DebugTuple`, `DebugSet`, `DebugList`, and `DebugMap`. This indicates that the structures have remaining items with `..`. This implements the ACP at <https://github.com/rust-lang/libs-team/issues/248>.
2024-07-21Make use of raw strings in `core::fmt::builders`Trevor Gross-37/+37
There are quite a few uses of escaped quotes. Turn these into raw strings within documentation and tests to make things easier to read.
2024-07-19Avoid ref when using format! for perfYuri Astrakhan-1/+1
Clean up a few minor refs in `format!` macro, as it has a tiny perf cost. A few more minor related cleanups.
2024-07-06Mark format! with must_use hintlukas-3/+3
2024-07-04stabilize `const_int_from_str`Skgland-1/+0
2024-06-29Stabilize `duration_abs_diff`Ole Bertram-1/+0
2024-06-25regression test for leaks in the the Filter::next_chunk implementationThe 8472-0/+13
previously next_chunk would forget items rejected by the filter
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-2/+0
This is possible now that inline const blocks are stable; the idea was even mentioned as an alternative when `uninit_array()` was added: <https://github.com/rust-lang/rust/pull/65580#issuecomment-544200681> > if it’s stabilized soon enough maybe it’s not worth having a > standard library method that will be replaceable with > `let buffer = [MaybeUninit::<T>::uninit(); $N];` Const array repetition and inline const blocks are now stable (in the next release), so that circumstance has come to pass, and we no longer have reason to want `uninit_array()` other than convenience. Therefore, let’s evaluate the inconvenience by not using `uninit_array()` in the standard library, before potentially deleting it entirely.
2024-06-22Auto merge of #116113 - kpreid:arcmut, r=dtolnaybors-0/+68
Generalize `{Rc,Arc}::make_mut()` to unsized types. * `{Rc,Arc}::make_mut()` now accept any type implementing the new unstable trait `core::clone::CloneToUninit`. * `CloneToUninit` is implemented for `T: Clone` and for `[T] where T: Clone`. * `CloneToUninit` is a generalization of the existing internal trait `alloc::alloc::WriteCloneIntoRaw`. * New feature gate: `clone_to_uninit` This allows performing `make_mut()` on `Rc<[T]>` and `Arc<[T]>`, which was not previously possible. --- Previous PR description, now obsolete: > Add `{Rc, Arc}::make_mut_slice()` > > These functions behave identically to `make_mut()`, but operate on `Arc<[T]>` instead of `Arc<T>`. > > This allows performing the operation on slices, which was not previously possible because `make_mut()` requires `T: Clone` (and slices, being `!Sized`, do not and currently cannot implement `Clone`). > > Feature gate: `make_mut_slice` try-job: test-various