about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2024-08-23Enable Alignment::new_unchecked precondition checkBen Kimock-2/+0
2024-08-23Change `f16` doctests in core to run on x86-64 linuxTrevor Gross-13/+13
Since `f16` now works on x86 and x86-64, change doctests to use this instead of aarch64. This is to make sure any changes get run in PR CI.
2024-08-23docs: correct panic conditions for rem_euclid and similar functionsbinarycat-8/+13
fixes https://github.com/rust-lang/rust/issues/128857
2024-08-23Move into_inner_unchecked back to the bottom of the impl blockNoa-25/+25
2024-08-23Put Pin::as_deref_mut in impl Pin<Ptr>Noa-59/+62
2024-08-23document & impl the transmutation modeled by `BikeshedIntrinsicFrom`Jack Wrenn-21/+350
Documents that `BikeshedIntrinsicFrom` models transmute-via-union, which is slightly more expressive than the transmute-via-cast implemented by `transmute_copy`. Additionally, we provide an implementation of transmute-via-union as a method on the `BikeshedIntrinsicFrom` trait with additional documentation on the boundary between trait invariants and caller obligations. Whether or not transmute-via-union is the right kind of transmute to model remains up for discussion [1]. Regardless, it seems wise to document the present behavior. [1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967
2024-08-23Rollup merge of #129276 - eduardosm:stabilize-char_indices_offset, r=AmanieuGuillaume Gomez-3/+13
Stabilize feature `char_indices_offset` Stabilized API: ```rust impl CharIndices<'_> { pub fn offset(&self) -> usize; } ``` Tracking issue: https://github.com/rust-lang/rust/issues/83871 Closes https://github.com/rust-lang/rust/issues/83871 I also attempted to improved the documentation to make it more clear that it returns the offset of the character that will be returned by the next call to `next()`.
2024-08-22fix typos in new pointer conversion docsbinarycat-8/+8
2024-08-22feat(core): Make `unbounded_shl{l,r}` unstably const and remove ↵Connor Horman-4/+4
`rustc_allow_const_fn_unstable`
2024-08-22Auto merge of #129398 - matthiaskrgr:rollup-50l01ry, r=matthiaskrgrbors-5/+10
Rollup of 8 pull requests Successful merges: - #128432 (WASI: forbid `unsafe_op_in_unsafe_fn` for `std::{os, sys}`) - #129373 (Add missing module flags for CFI and KCFI sanitizers) - #129374 (Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked`) - #129376 (Change `assert_unsafe_precondition` docs to refer to `check_language_ub`) - #129382 (Add `const_cell_into_inner` to `OnceCell`) - #129387 (Advise against removing the remaining Python scripts from `tests/run-make`) - #129388 (Do not rely on names to find lifetimes.) - #129395 (Pretty-print own args of existential projections (dyn-Trait w/ GAT constraints)) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-22stabilize const_fn_floating_point_arithmeticRalf Jung-1/+1
2024-08-22Rollup merge of #129382 - tgross35:once-cell-const-into-inner, r=NoratriebMatthias Krüger-1/+2
Add `const_cell_into_inner` to `OnceCell` `Cell` and `RefCell` have their `into_inner` methods const unstable. `OnceCell` has the same logic, so add it under the same gate. Tracking issue: https://github.com/rust-lang/rust/issues/78729
2024-08-22Rollup merge of #129376 - ↵Matthias Krüger-1/+1
ChaiTRex:assert_unsafe_precondition_check_language_ub, r=workingjubilee,the8472 Change `assert_unsafe_precondition` docs to refer to `check_language_ub`
2024-08-22Rollup merge of #129374 - ↵Matthias Krüger-3/+7
ChaiTRex:digit_unchecked_assert_unsafe_precondition, r=scottmcm Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked`
2024-08-22Auto merge of #129365 - matthiaskrgr:rollup-ebwx6ya, r=matthiaskrgrbors-46/+565
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-22fix(core): Use correct operations/values in `unbounded_shr` doctestsConnor Horman-2/+2
2024-08-21chore: `x fmt`Connor Horman-1/+1
2024-08-21fix(core): Add `#![feature(unbounded_shifts)]` to doctests for ↵Connor Horman-2/+6
`unbounded_shr`/`unbounded_shl`
2024-08-21Add `const_cell_into_inner` to `OnceCell`Trevor Gross-1/+2
`Cell` and `RefCell` have their `into_inner` methods const unstable. `OnceCell` has the same logic, so add it under the same gate. Tracking issue: https://github.com/rust-lang/rust/issues/78729
2024-08-21chore: `x fmt` and hopefully fix the tidy issueConnor Horman-12/+12
2024-08-21Change `assert_unsafe_precondition` docs to refer to `check_language_ub`Chai T. Rex-1/+1
2024-08-21chore: Also format the control flowConnor Horman-8/+8
2024-08-21Manually format functions and use `rhs` instead of `v` from my CE testingConnor Horman-17/+17
2024-08-21feat(core): Add implementations for `unbounded_shl`/`unbounded_shr`Connor Horman-0/+114
2024-08-21Use `assert_unsafe_precondition!` in `AsciiChar::digit_unchecked`Chai T. Rex-3/+7
2024-08-21Rollup merge of #129321 - krtab:float_sum, r=workingjubileeMatthias Krüger-2/+30
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-46/+565
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-21Rollup merge of #129312 - tbu-:pr_str_not_impl_error, r=NoratriebMatthias Krüger-1/+1
Fix stability attribute of `impl !Error for &str` It was introduced in bf7611d55ee6e24647aefc4d1c82b1dba0164536 (#99917), which was included in Rust 1.65.0.
2024-08-21Fix stability attribute of `impl !Error for &str`Tobias Bucher-1/+1
It was introduced in bf7611d55ee6e24647aefc4d1c82b1dba0164536 (#99917), which was included in Rust 1.65.0.
2024-08-21Auto merge of #126556 - saethlin:layout-precondition, r=joboetbors-8/+23
Add a precondition check for Layout::from_size_align_unchecked Ran into this while looking into https://github.com/rust-lang/miri/issues/3679. This is of course not the cause of the ICE, but the reproducer doesn't encounter a precondition check and it ought to.
2024-08-20Try to golf down the amount of code in LayoutBen Kimock-8/+3
2024-08-20Implement `ptr::fn_addr_eq`Urgau-0/+27
2024-08-20Change neutral element of <fNN as iter::Sum> to neg_zeroArthur Carcano-2/+30
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-13/+10
2024-08-19Add a precondition check for Layout::from_size_align_uncheckedBen Kimock-7/+27
2024-08-19Stabilize feature `char_indices_offset`Eduardo Sánchez Muñoz-3/+13
2024-08-18Document futility of printing temporary pointersKornel-2/+10
2024-08-18soft-deprecate the addr_of macrosRalf Jung-0/+6
2024-08-17Auto merge of #126877 - GrigorenkoPV:clone_to_uninit, r=dtolnaybors-105/+190
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-08-17Auto merge of #128598 - RalfJung:float-comments, r=workingjubileebors-500/+85
float to/from bits and classify: update for float semantics RFC With https://github.com/rust-lang/rfcs/pull/3514 having been accepted, it is clear that hardware which e.g. flushes subnormal to zero is just non-conformant from a Rust perspective -- this is a hardware bug, or maybe an LLVM backend bug (where LLVM doesn't lower floating-point ops in a way that they have the standardized behavior). So update the comments here to make it clear that we don't have to do any of this, we're just being nice. Also remove the subnormal/NaN checks from the (unstable) const-version of to/from-bits; they are not needed since we decided with the aforementioned RFC that it is okay to get a different result at const-time and at run-time. r? `@workingjubilee` since I think you wrote many of the comments I am editing here.
2024-08-17Auto merge of #106943 - mina86:exact_size_take_repeat, r=dtolnaybors-0/+147
Implement DoubleEnded and ExactSize for Take<Repeat> and Take<RepeatWith> Repeat iterator always returns the same element and behaves the same way backwards and forwards. Take iterator can trivially implement backwards iteration over Repeat inner iterator by simply doing forwards iteration. DoubleEndedIterator is not currently implemented for Take<Repeat<T>> because Repeat doesn’t implement ExactSizeIterator which is a required bound on DEI implementation for Take. Similarly, since Repeat is an infinite iterator which never stops, Take can trivially know how many elements it’s going to return. This allows implementing ExactSizeIterator on Take<Repeat<T>>. While at it, observe that ExactSizeIterator can also be implemented for Take<RepeatWhile<F>> so add that implementation too. Since in contrast to Repeat, RepeatWhile doesn’t guarante to always return the same value, DoubleEndedIterator isn’t implemented. Those changes render core::iter::repeat_n somewhat redundant. Issue: https://github.com/rust-lang/rust/issues/104434 Issue: https://github.com/rust-lang/rust/issues/104729 - [ ] ACP: https://github.com/rust-lang/libs-team/issues/120 (this is actually ACP for repeat_n but this is nearly the same functionality so hijacking it so both approaches can be discussed in one place)
2024-08-16Auto merge of #116528 - daxpedda:stabilize-ready-into-inner, r=dtolnaybors-2/+1
Stabilize `Ready::into_inner()` This PR stabilizes `Ready::into_inner()`. Tracking issue: #101196. Implementation PR: #101189. Closes #101196.
2024-08-16Rollup merge of #129086 - slanterns:is_none_or, r=dtolnayMatthias Krüger-3/+1
Stabilize `is_none_or` Closes: https://github.com/rust-lang/rust/issues/126383. `@rustbot` label: +T-libs-api r? libs-api
2024-08-16float to/from bits and classify: update comments regarding non-conformant ↵Ralf Jung-500/+85
hardware
2024-08-15Rollup merge of #128064 - ijackson:noop-waker-doc, r=workingjubileeJubilee-1/+19
Improve docs for Waker::noop and LocalWaker::noop * Add a warning about a likely misuse. (See my commit message for longer rationale.) * Apply some probably-accidentally-omitted changes to `LocalWaker`'s docs * Add a comment about the clone-and-hack of the docs I have used [semantic linefeeds](https://rhodesmill.org/brandon/2012/one-sentence-per-line/) for the docs formatting.
2024-08-15Add cautionary paragraph about noop wakers.Ian Jackson-0/+8
Based on a suggestion from @kpreid, with some further editing.
2024-08-15Rollup merge of #128946 - orlp:faster-ip-hash, r=joboetMatthias Krüger-2/+23
Hash Ipv*Addr as an integer The `Ipv4Addr` and `Ipv6Addr` structs always have a fixed size, but directly derive `Hash`. This causes them to call the bytestring hasher implementation, which adds extra work for most hashers. This PR converts the internal representation to a fixed-width integer before passing to the hasher to prevent this.
2024-08-15Rollup merge of #128925 - dingxiangfei2009:smart-ptr-helper-attr, ↵Matthias Krüger-1/+1
r=compiler-errors derive(SmartPointer): register helper attributes Fix #128888 This PR enables built-in macros to register helper attributes, if any, to support correct name resolution in the correct lexical scope under the macros. Also, `#[pointee]` is moved into the scope under `derive(SmartPointer)`. cc `@Darksonn` `@davidtwco`
2024-08-14apply #[optimize(size)] to #[cold] ones and part of the panick machineryThe 8472-7/+8
2024-08-14Rollup merge of #128954 - zachs18:fromresidual-no-default, r=scottmcm许杰友 Jieyou Xu (Joe)-2/+33
Explicitly specify type parameter on FromResidual for Option and ControlFlow. ~~Remove type parameter default `R = <Self as Try>::Residual` from `FromResidual`~~ _Specify default type parameter on `FromResidual` impls in the stdlib_ to work around https://github.com/rust-lang/rust/issues/99940 / https://github.com/rust-lang/rust/issues/87350 ~~as mentioned in https://github.com/rust-lang/rust/issues/84277#issuecomment-1773259264~~. This does not completely fix the issue, but works around it for `Option` and `ControlFlow` specifically (`Result` does not have the issue since it already did not use the default parameter of `FromResidual`). ~~(Does this need an ACP or similar?)~~ ~~This probably needs at least an FCP since it changes the API described in [the RFC](https://github.com/rust-lang/rfcs/pull/3058). Not sure if T-lang, T-libs-api, T-libs, or some combination (The tracking issue is tagged T-lang, T-libs-api).~~ This probably doesn't need T-lang input, since it is not changing the API of `FromResidual` from the RFC? Maybe needs T-libs-api FCP?