about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-08-25Rollup merge of #129487 - ↵Matthias Krüger-0/+6
GrigorenkoPV:repr_transparent_external_private_fields, r=compiler-errors repr_transparent_external_private_fields: special-case some std types Fixes #129470 ```@rustbot``` label +A-lint +L-repr_transparent_external_private_fields
2024-08-25ub_checks intrinsics: fall back to cfg(ub_checks)Ralf Jung-2/+3
2024-08-25Auto merge of #129521 - matthiaskrgr:rollup-uigv77m, r=matthiaskrgrbors-2/+28
Rollup of 9 pull requests Successful merges: - #128596 (stabilize const_fn_floating_point_arithmetic) - #129199 (make writes_through_immutable_pointer a hard error) - #129246 (Retroactively feature gate `ConstArgKind::Path`) - #129290 (Pin `cc` to 1.0.105) - #129323 (Implement `ptr::fn_addr_eq`) - #129500 (remove invalid `TyCompat` relation for effects) - #129501 (panicking: improve hint for Miri's RUST_BACKTRACE behavior) - #129505 (interpret: ImmTy: tighten sanity checks in offset logic) - #129510 (Fix `elided_named_lifetimes` in code) r? `@ghost` `@rustbot` modify labels: rollup
2024-08-24Rollup merge of #129449 - coolreader18:pin-as_deref_mut-signature, r=dtolnayTrevor Gross-70/+73
Put Pin::as_deref_mut in impl Pin<Ptr> / rearrange Pin methods Tracking issue: #86918 Based on the suggestion in https://github.com/rust-lang/rust/issues/86918#issuecomment-2189367582 > Some advantages: > > * Synergy with the existing `as_ref` and `as_mut` signatures (stable since Rust 1.33) > > * Lifetime elision reduces noise in the signature > > * Turbofish less verbose: `Pin::<&mut T>::as_deref_mut` vs `Pin::<&mut Pin<&mut T>>::as_deref_mut` The comment seemed to imply that `Pin::as_ref` and `Pin::as_mut` already share an impl block, which they don't. So, I rearranged it so that they do, and we can see which looks better in the docs. <details><summary><b>Docs screenshots</b></summary> Current nightly: ![image](https://github.com/user-attachments/assets/b432cb82-8f4b-48ae-bafc-2fe49d0ad48c) `Pin::as_deref_mut` moved into the same block as `as_mut`: ![image](https://github.com/user-attachments/assets/f9b35722-6a88-4465-ad1c-28d8e91902ac) `Pin::as_ref`, `as_mut`, and `as_deref_mut` all in the same block: ![image](https://github.com/user-attachments/assets/9a1b2bf0-70a6-4751-b13f-390f1d575244) </details> I think I like the last one the most; obviously I'm biased since I'm the one who rearranged it, but it doesn't make sense to me to have `as_ref` methods split up by an `into_inner` method. r? dtolnay
2024-08-24Rollup merge of #128735 - jieyouxu:pr-120176-revive, r=cjgillotTrevor Gross-0/+1
Add a special case for `CStr`/`CString` in the `improper_ctypes` lint Revives #120176. Just needed to bless a test and fix an argument, but seemed reasonable to me otherwise. Instead of saying to "consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct", we now tell users to "Use `*const ffi::c_char` instead, and pass the value from `CStr::as_ptr()`" when the type involved is a `CStr` or a `CString`. The suggestion is not made for `&mut CString` or `*mut CString`. r? ``````@cjgillot`````` (since you were the reviewer of the original PR #120176, but feel free to reroll)
2024-08-24rustdoc: clean up tuple <-> primitive conversion docsMichael Howell-15/+21
This adds a minor missing feature to `fake_variadic`, so that it can render `impl From<(T,)> for [T; 1]` correctly.
2024-08-24Rollup merge of #129500 - fee1-dead-contrib:fxrel, r=compiler-errorsMatthias Krüger-1/+0
remove invalid `TyCompat` relation for effects if the current impl uses `Maybe` (`impl const`), the parent impl must use `Maybe` (`impl const`) as well. I'd like to rename `TyCompat` to `Sub` which is probably clearer. But it would conflict with my other PR. r? ``@rust-lang/project-const-traits``
2024-08-24Rollup merge of #129323 - Urgau:ptr_fn_addr_eq, r=Mark-SimulacrumMatthias Krüger-0/+27
Implement `ptr::fn_addr_eq` This PR implements https://github.com/rust-lang/libs-team/issues/323: `ptr::fn_addr_eq`. r? libs
2024-08-24Rollup merge of #128596 - RalfJung:const_fn_floating_point_arithmetic, ↵Matthias Krüger-1/+1
r=nnethercote stabilize const_fn_floating_point_arithmetic Part of https://github.com/rust-lang/rust/issues/128288 Fixes https://github.com/rust-lang/rust/issues/57241 The existing test `tests/ui/consts/const_let_eq_float.rs` ([link](https://github.com/RalfJung/rust/blob/const_fn_floating_point_arithmetic/tests/ui/consts/const_let_eq_float.rs)) covers the basics, and also Miri has extensive tests covering the interpreter's float machinery. Also, that machinery can already be used on stable inside `const`/`static` initializers, just not inside `const fn`. This was explicitly called out in https://github.com/rust-lang/rfcs/pull/3514 so in a sense t-lang just recently already FCP'd this, but let's hear from them whether they want another FCP for the stabilization here or whether that was covered by the FCP for the RFC. Cc ``@rust-lang/lang`` ### Open items - [x] Update the Reference: https://github.com/rust-lang/reference/pull/1566
2024-08-24New `#[rustc_pub_transparent]` attributePavel Grigorenko-0/+6
2024-08-24remove invalid `TyCompat` relation for effectsDeadbeef-1/+0
2024-08-24Pass `fmt::Arguments` by reference to `PanicInfo` and `PanicMessage`StackOverflowExcept1on-8/+8
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-12/+212
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/+2
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-12/+212
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/+2
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-12/+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