about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-02-08Step all bootstrap cfgs forwardMark Rousskov-136/+8
This also takes care of other bootstrap-related changes.
2024-02-08Bump version placeholdersMark Rousskov-34/+34
2024-02-08Auto merge of #120558 - oli-obk:missing_impl_item_ice, r=estebankbors-36/+0
Stop bailing out from compilation just because there were incoherent traits fixes #120343 but also has a lot of "type annotations needed" fallout. Some are fixed in the second commit.
2024-02-07Fix whitespace issues that tidy caughtVenus Xeon-Blonde-4/+4
2024-02-07Add documentation on `str::starts_with`Venus Xeon-Blonde-0/+14
Add documentation about a current footgun of `str::starts_with`
2024-02-08Auto merge of #120521 - reitermarkus:generic-nonzero-constructors, r=dtolnaybors-87/+99
Make `NonZero` constructors generic. This makes `NonZero` constructors generic, so that `NonZero::new` can be used without turbofish syntax. Tracking issue: https://github.com/rust-lang/rust/issues/120257 ~~I cannot figure out how to make this work with `const` traits. Not sure if I'm using it wrong or whether there's a bug:~~ ```rust 101 | if n == T::ZERO { | ^^^^^^^^^^^^ expected `host`, found `true` | = note: expected constant `host` found constant `true` ``` r? `@dtolnay`
2024-02-08Auto merge of #120381 - fee1-dead-contrib:reconstify-add, r=compiler-errorsbors-1/+3
Reconstify `Add` r? project-const-traits I'm not happy with the ui test changes (or failures because I did not bless them and include the diffs in this PR). There is at least some bugs I need to look and try fix: 1. A third duplicated diagnostic when a consumer crate that does not have `effects` enabled has a trait selection error for an upstream const_trait trait. See tests/ui/ufcs/ufcs-qpath-self-mismatch.rs. 2. For some reason, making `Add` a const trait would stop us from suggesting `T: Add` when we try to add two `T`s without that bound. See tests/ui/suggestions/issue-97677.rs
2024-02-07Make `io::BorrowedCursor::advance` safeBenoît du Garreau-1/+21
This also keeps the old `advance` method under `advance_unchecked` name. This makes pattern like `std::io::default_read_buf` safe to write.
2024-02-07Replace `transmute_copy` with `ptr::read`.Markus Reiter-1/+2
2024-02-07Don't use `assert_unsafe_precondition` twice.Markus Reiter-12/+10
2024-02-07Make `NonZero` constructors generic.Markus Reiter-71/+84
2024-02-07Simplify `impl_zeroable_primitive` macro.Markus Reiter-13/+13
2024-02-06Auto merge of #117905 - RalfJung:no-const-mut, r=lcnrbors-12/+16
revert stabilization of const_intrinsic_copy `@rust-lang/wg-const-eval` I don't know what we were thinking when we approved https://github.com/rust-lang/rust/pull/97276... const-eval isn't supposed to be able to mutate anything yet! It's also near impossible to actually call `copy` in const on stable since `&mut` expressions are generally unstable. However, there's one exception... ```rust static mut INT: i32 = unsafe { let val = &mut [1]; // `&mut` on arrays is allowed in `static mut` (val as *mut [i32; 1]).copy_from(&[42], 1); val[0] }; fn main() { unsafe { dbg!(INT); } } ``` Inside `static mut`, we accept some `&mut` since ~forever, to make `static mut FOO: &mut [T] = &mut [...];` work. We reject any attempt to actually write to that mutable reference though... except for the `copy` functions. I think we should revert stabilizing these functions that take `*mut`, and then re-stabilize them together with `ptr.write` once mutable references are stable. (This will likely fail on PowerPC until https://github.com/rust-lang/stdarch/pull/1497 lands. But we'll need a crater run first anyway.)
2024-02-06Harmonize blanket implementations for AsyncFn* traitsMichael Goulet-14/+37
2024-02-06Bless tests, add commentsMichael Goulet-2/+19
2024-02-06Teach typeck/borrowck/solvers how to deal with async closuresMichael Goulet-0/+8
2024-02-05revert stabilization of const_intrinsic_copyRalf Jung-12/+16
2024-02-05Auto merge of #117372 - Amanieu:stdarch_update, r=Mark-Simulacrumbors-4/+0
Update stdarch submodule Splits up #27731 into multiple tracking issues. Closes #27731
2024-02-05Remove some invalid cfg(doc) codeOli Scherer-36/+0
2024-02-05Rollup merge of #120384 - wackbyte:array-equality-generics, r=Mark-SimulacrumMatthias Krüger-36/+36
Use `<T, U>` for array/slice equality `impl`s Makes the trait implementation documentation for arrays and slices appear more consistent. [Example](https://doc.rust-lang.org/1.75.0/std/primitive.array.html): mixed `A`, `B`, and `U`. ![List of PartialEq implementations for arrays](https://github.com/wackbyte/rust/assets/29505620/823c010e-ee57-4de1-885b-a1cd6dcaf85f) This change makes them all `U`.
2024-02-05Rollup merge of #118960 - tvallotton:local_waker, r=Mark-SimulacrumMatthias Krüger-37/+353
Add LocalWaker and ContextBuilder types to core, and LocalWake trait to alloc. Implementation for #118959.
2024-02-05Rollup merge of #115386 - RalfJung:partial-eq-chain, r=dtolnayMatthias Krüger-8/+52
PartialEq, PartialOrd: update and synchronize handling of transitive chains It was brought up in https://internals.rust-lang.org/t/total-equality-relations-as-std-eq-rhs/19232 that we currently have a gap in our `PartialEq` rules, which this PR aims to close: > For example, with PartialEq's conditions you may have a = b = c = d ≠ a (where a and c are of type A, b and d are of type B). The second commit fixes https://github.com/rust-lang/rust/issues/87067 by updating PartialOrd to handle the requirements the same way PartialEq does.
2024-02-05Rollup merge of #119481 - romanows:fix-doc-select-nth-unstable, ↵Matthias Krüger-7/+7
r=Mark-Simulacrum Clarify ambiguity in select_nth_unstable docs Original docs for `select_nth_unstable` family of functions were ambiguous as to whether "the element at `index`" was the element at `index` before the function reordered the elements or after the function reordered the elements. The most helpful change in this PR is to change the given examples to make this absolutely clear. Before, "the element at `index`" was the same value before and after the reordering, so it didn't help disambiguate the meaning. I've changed the example for `select_nth_unstable` and `select_nth_unstable_by` so that "the element at `index`" is different before and after the reordering, which clears up the ambiguity. The function `select_nth_unstable_by_key` already had an example that was unambiguous. In an attempt to clear up the ambiguity from the get-go, I've added a bit of redundancy to the text. Now the docs refer to "the element at `index` *after the reordering*".
2024-02-04Reconstify `Add`Deadbeef-1/+3
2024-02-03Docs for std::ptr::slice_from_raw_partsKornel-2/+26
2024-02-02fix typoRalf Jung-2/+2
Co-authored-by: teor <teor@riseup.net>
2024-02-01Revert unsound libcore changes of #119911Oli Scherer-385/+149
2024-01-30Rollup merge of #120295 - reitermarkus:remove-ffi-nonzero, r=dtolnayGuillaume Gomez-50/+14
Remove `raw_os_nonzero` feature. This feature is superseded by a generic `NonZero` type: https://github.com/rust-lang/rust/issues/120257 Closes https://github.com/rust-lang/rust/issues/82363.
2024-01-30Rollup merge of #120424 - RalfJung:raw-ptr-meta, r=NilstriebGuillaume Gomez-14/+14
raw pointer metadata API: data address -> data pointer A pointer consists of [more than just an address](https://github.com/rust-lang/rfcs/pull/3559), so let's not equate "pointer" and "address" in these docs.
2024-01-30Update feature names for new stdarchAmanieu d'Antras-4/+0
2024-01-29Remove `raw_os_nonzero` feature.Markus Reiter-50/+14
2024-01-29Rollup merge of #116677 - joshlf:patch-11, r=RalfJungDylan DPC-0/+24
References refer to allocated objects Partially addresses https://github.com/rust-lang/unsafe-code-guidelines/issues/465
2024-01-29raw pointer metadata API: data address -> data pointerRalf Jung-14/+14
2024-01-27Update primitive_docs.rsJoshua Liebow-Feeser-7/+12
2024-01-27Switch `NonZero` alias direction.Markus Reiter-19/+41
2024-01-27Auto merge of #120417 - matthiaskrgr:rollup-5rszkmd, r=matthiaskrgrbors-1/+0
Rollup of 6 pull requests Successful merges: - #118182 (Properly recover from trailing attr in body) - #119641 (Remove feature not required by `Ipv6Addr::to_cononical` doctest) - #119957 (fix: correct suggestion arg for impl trait) - #120386 (ScopeTree: remove destruction_scopes as unused) - #120398 (Improve handling of numbers in `IntoDiagnosticArg`) - #120399 (Remove myself from review rotation) r? `@ghost` `@rustbot` modify labels: rollup
2024-01-27Rollup merge of #119641 - eopb:std-unused-ip-feature, r=ChrisDentonMatthias Krüger-1/+0
Remove feature not required by `Ipv6Addr::to_cononical` doctest The feature does not seem to be required by this doctest.
2024-01-27Auto merge of #111379 - nyurik:intersperse-speed-up, r=cuviperbors-49/+98
Boost iterator intersperse(_with) performance I did some benchmark digging into the `intersperse` and `intersperse_with` code as part of [this discussion](https://internals.rust-lang.org/t/add-iterate-with-separators-iterator-function/18781/13), and as a result I optimized them a bit, without relying on the peekable iterator. See also [full benchmark repo](https://github.com/nyurik/intersperse_perf) Benchmarks show near 2x performance improvements with the simple `sum` [benchmarks](https://gist.github.com/nyurik/68b6c9b3d90f0d14746d4186bf8fa1e2): ![image](https://user-images.githubusercontent.com/1641515/237005195-16aebef4-9eed-4514-8b7c-da1d1f5bd9e0.png)
2024-01-26Rollup merge of #120366 - RalfJung:is_val_statically_known, r=cuviperMatthias Krüger-1/+1
mark a doctest with UB as no_run https://github.com/rust-lang/rust/pull/119911 added a doctest with UB. That one shouldn't be run, or else Miri will complain.
2024-01-26Rollup merge of #120311 - mina86:h, r=cuviperMatthias Krüger-0/+16
core: add `From<core::ascii::Char>` implementations Introduce `From<core::ascii::Char>` implementations for all unsigned numeric types and `char`. This matches the API of `char` type. Issue: https://github.com/rust-lang/rust/issues/110998
2024-01-26Rollup merge of #119562 - LegionMammal978:rename-pin-pointer, r=Amanieu,dtolnayMatthias Krüger-20/+26
Rename `pointer` field on `Pin` A few days ago, I was helping another user create a self-referential type using `PhantomPinned`. However, I noticed an odd behavior when I tried to access one of the type's fields via `Pin`'s `Deref` impl: ```rust use std::{marker::PhantomPinned, ptr}; struct Pinned { data: i32, pointer: *const i32, _pin: PhantomPinned, } fn main() { let mut b = Box::pin(Pinned { data: 42, pointer: ptr::null(), _pin: PhantomPinned, }); { let pinned = unsafe { b.as_mut().get_unchecked_mut() }; pinned.pointer = &pinned.data; } println!("{}", unsafe { *b.pointer }); } ``` ```rust error[E0658]: use of unstable library feature 'unsafe_pin_internals' --> <source>:19:30 | 19 | println!("{}", unsafe { *b.pointer }); | ^^^^^^^^^ error[E0277]: `Pinned` doesn't implement `std::fmt::Display` --> <source>:19:20 | 19 | println!("{}", unsafe { *b.pointer }); | ^^^^^^^^^^^^^^^^^^^^^ `Pinned` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `Pinned` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) ``` Since the user named their field `pointer`, it conflicts with the `pointer` field on `Pin`, which is public but unstable since Rust 1.60.0 with #93176. On versions from 1.33.0 to 1.59.0, where the field on `Pin` is private, this program compiles and prints `42` as expected. To avoid this confusing behavior, this PR renames `pointer` to `__pointer`, so that it's less likely to conflict with a `pointer` field on the underlying type, as accessed through the `Deref` impl. This is technically a breaking change for anyone who names their field `__pointer` on the inner type; if this is undesirable, it could be renamed to something more longwinded. It's also a nightly breaking change for any external users of `unsafe_pin_internals`.
2024-01-26Rollup merge of #103522 - Dylan-DPC:76118/array-methods-stab, r=dtolnayMatthias Krüger-7/+2
stabilise array methods Closes #76118 Stabilises the remaining array methods FCP is yet to be carried out for this There wasn't a clear consensus on the naming, but all the other alternatives had some flaws as discussed in the tracking issue and there was a silence on this issue for a year
2024-01-26Use `<T, U>` for array/slice equality `impl`swackbyte-36/+36
Makes the trait implementation documentation for arrays and slices appear more consistent.
2024-01-26Rollup merge of #117678 - niklasf:stabilize-slice_group_by, r=dtolnayMatthias Krüger-58/+50
Stabilize `slice_group_by` Renamed "group by" to "chunk by" a per #80552. Newly stable items: * `core::slice::ChunkBy` * `core::slice::ChunkByMut` * `[T]::chunk` * `[T]::chunk_by` Closes #80552.
2024-01-26mark a doctest with UB as no_runRalf Jung-1/+1
2024-01-26Rollup merge of #119466 - Sky9x:str_from_raw_parts, r=dtolnayMatthias Krüger-1/+42
Initial implementation of `str::from_raw_parts[_mut]` ACP (accepted): rust-lang/libs-team#167 Tracking issue: #119206 Thanks to ``@Kixiron`` for previous work on this (#107207) ``@rustbot`` label +T-libs-api -T-libs r? ``@thomcc`` Closes #107207.
2024-01-26Rollup merge of #107464 - WaffleLapkin:all_that_remains_of_lines, r=dtolnayMatthias Krüger-0/+25
Add `str::Lines::remainder` Based on https://github.com/rust-lang/rust/pull/98453. This PR adds `str::Lines::remainder` similarly to [other remainder function on str split iterators](https://github.com/rust-lang/rust/issues/77998).
2024-01-25use checked_add for upper boundYuri Astrakhan-2/+2
2024-01-25Update library/core/src/iter/adapters/intersperse.rsYuri Astrakhan-2/+2
Co-authored-by: Josh Stone <cuviper@gmail.com>
2024-01-26Auto merge of #116167 - RalfJung:structural-eq, r=lcnrbors-5/+23
remove StructuralEq trait The documentation given for the trait is outdated: *all* function pointers implement `PartialEq` and `Eq` these days. So the `StructuralEq` trait doesn't really seem to have any reason to exist any more. One side-effect of this PR is that we allow matching on some consts that do not implement `Eq`. However, we already allowed matching on floats and consts containing floats, so this is not new, it is just allowed in more cases now. IMO it makes no sense at all to allow float matching but also sometimes require an `Eq` instance. If we want to require `Eq` we should adjust https://github.com/rust-lang/rust/pull/115893 to check for `Eq`, and rule out float matching for good. Fixes https://github.com/rust-lang/rust/issues/115881