about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2024-06-30Rollup merge of #126906 - GrigorenkoPV:fixme-split_at_first, r=Mark-SimulacrumMatthias Krüger-6/+2
Small fixme in core now that split_first has no codegen issues https://github.com/rust-lang/rust/issues/109328#issuecomment-1677366881 BTW, I have a crate implementing exactly this kind of an iterator: https://github.com/GrigorenkoPV/head-tail-iter and I was wondering if it would be worthwhile to try and make an ACP for it to get it included in std (or maybe itertools). My only doubt is that it kinda incentives writing O(n^2) algorithms and is not the hard to replace with a `while let` loop (just as in this PR).
2024-06-30Rollup merge of #126705 - safinaskar:panic, r=Mark-SimulacrumMatthias Krüger-5/+2
Updated docs on `#[panic_handler]` in `library/core/src/lib.rs`
2024-06-30Auto merge of #127133 - matthiaskrgr:rollup-jxkp3yf, r=matthiaskrgrbors-1/+1
Rollup of 9 pull requests Successful merges: - #123237 (Various rustc_codegen_ssa cleanups) - #126960 (Improve error message in tidy) - #127002 (Implement `x perf` as a separate tool) - #127081 (Add a run-make test that LLD is not being used by default on the x64 beta/stable channel) - #127106 (Improve unsafe extern blocks diagnostics) - #127110 (Fix a error suggestion for E0121 when using placeholder _ as return types on function signature.) - #127114 (fix: prefer `(*p).clone` to `p.clone` if the `p` is a raw pointer) - #127118 (Show `used attribute`'s kind for user when find it isn't applied to a `static` variable.) - #127122 (Remove uneccessary condition in `div_ceil`) r? `@ghost` `@rustbot` modify labels: rollup
2024-06-29Print `TypeId` as a `u128` for `Debug`Trevor Gross-1/+12
Since <https://github.com/rust-lang/rust/pull/121358>, `TypeId` is represented as a `(u64, u64)`. This also made the debug implementation a lot larger, which is especially apparent with pretty formatting. Make this less noisy by converting the inner value back to a `u128` then printing as a tuple struct. Current: TypeId { t: (1403077013027291752, 4518903163082958039) } TypeId { t: ( 1403077013027291752, 4518903163082958039, ), } New: TypeId(25882202575019293479932656973818029271) TypeId( 25882202575019293479932656973818029271, )
2024-06-29Rollup merge of #127122 - TDecking:div_ceil, r=NilstriebMatthias Krüger-1/+1
Remove uneccessary condition in `div_ceil` Previously, `div_ceil` for unsigned integers had a `rhs > 0` for rounding. That condition however is always fulfilled, since `rhs == 0` would mean a division by zero earlier.
2024-06-29Auto merge of #120639 - fee1-dead-contrib:new-effects-desugaring, r=oli-obkbors-0/+47
Implement new effects desugaring cc `@rust-lang/project-const-traits.` Will write down notes once I have finished. * [x] See if we want `T: Tr` to desugar into `T: Tr, T::Effects: Compat<true>` * [x] Fix ICEs on `type Assoc: ~const Tr` and `type Assoc<T: ~const Tr>` * [ ] add types and traits to minicore test * [ ] update rustc-dev-guide Fixes #119717 Fixes #123664 Fixes #124857 Fixes #126148
2024-06-29Stabilize `duration_abs_diff`Ole Bertram-2/+3
2024-06-29small correction to fmt::Pointer implSky-2/+1
the `expose_provenance` method does not require `T: Sized`
2024-06-29Remove uneccessary condition in `div_ceil`Tobias Decking-1/+1
2024-06-29Updated docs on `#[panic_handler]` in `library/core/src/lib.rs`Askar Safin-5/+2
2024-06-29Rollup merge of #127073 - Sky9x:unnecessary-seqcst, r=NilstriebGuillaume Gomez-1/+1
Remove unnecessary SeqCst in `impl fmt::Pointer for AtomicPtr` Unnecessarily strict ordering.
2024-06-29Rollup merge of #127072 - Sky9x:docs-includes-vs-does-include, r=scottmcmGuillaume Gomez-4/+4
docs: say "includes" instead of "does include" Provides more visual difference between the negative ("does not include") and the positive ("includes"). Both phrases have the same meaning.
2024-06-28Rollup merge of #127071 - Sky9x:remove-ptr-to-from-bits, r=scottmcmMatthias Krüger-131/+0
Remove (deprecated & unstable) {to,from}_bits pointer methods These unstable methods have been deprecated for more than a year (since #95583). Remove them. See https://github.com/rust-lang/rust/issues/91126#issuecomment-1835796457 and https://github.com/rust-lang/rust/pull/110441/files#r1169574509. Closes #91126. r? `@scottmcm`
2024-06-28Rollup merge of #127070 - Sky9x:unit-const-param-ty, r=BoxyUwUMatthias Krüger-4/+1
add () to the marker_impls macro for ConstParamTy Seems to have escaped bootstrap
2024-06-28Rollup merge of #127055 - shepmaster:hash-finish-must-use, r=dtolnayMatthias Krüger-0/+1
Mark Hasher::finish as #[must_use]
2024-06-28address review commentsDeadbeef-3/+8
2024-06-28general fixups and turn `TODO`s into `FIXME`sDeadbeef-1/+3
2024-06-28Implement `Min` trait in new solverDeadbeef-4/+5
2024-06-28implement new effects desugaringDeadbeef-0/+39
2024-06-28Rollup merge of #126956 - joboet:fmt_no_extern_ty, r=RalfJungMatthias Krüger-21/+31
core: avoid `extern type`s in formatting infrastructure ```@RalfJung``` [said](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Use.20of.20.60extern.20type.60.20in.20formatting.20machinery/near/446552837): >How attached are y'all to using `extern type` in the formatting machinery? Seems like this was introduced a [long time ago](https://github.com/rust-lang/rust/commit/34ef8f5441d5335c4177abd622383ed34a6e9315). However, it's also [not really compatible with Stacked Borrows](https://github.com/rust-lang/unsafe-code-guidelines/issues/256), and only works currently because we effectively treat references-to-extern-type almost like raw pointers in Stacked Borrows -- which of course is unsound, it's not how LLVM works. I was planning to make Miri emit a warning when this happens to avoid cases like [this](https://github.com/rust-lang/rust/issues/126814#issuecomment-2183816373) where people use extern type specifically to silence Miri without realizing what happens. but with the formatting machinery using extern type, this warning would just show up everywhere... > > The "proper" way to do this in Stacked Borrows is to use raw pointers (or `NonNull`). This PR does just that. r? ```@RalfJung```
2024-06-28Remove unnecessary SeqCst in `impl fmt::Pointer for AtomicPtr`Sky-1/+1
2024-06-28docs: say "includes" instead of "does include"Sky-4/+4
2024-06-27Remove (deprecated & unstable) {to,from}_bits pointer methodsSky-131/+0
2024-06-27add () to the marker_impls macro for ConstParamTySky-4/+1
seems to have escaped bootstrap
2024-06-27Mark `Hasher::finish` as #[must_use]Jake Goulding-0/+1
2024-06-27fix least significant digits of f128 associated constantsTrevor Spiteri-3/+3
While the numbers are parsed to the correct value, the decimal numbers in the source were rounded to zero instead of to the nearest, making the literals different from the values shown in the documentation.
2024-06-27core: improve commentjoboet-2/+2
Co-authored-by: Ralf Jung <post@ralfj.de>
2024-06-26Auto merge of #126608 - tgross35:f16-f128-library, r=Mark-Simulacrumbors-58/+1378
Add more constants, functions, and tests for `f16` and `f128` This adds everything that was in some way blocked on const eval, since https://github.com/rust-lang/rust/pull/126429 landed. There is a lot of `cfg(bootstrap)` since that is a fairly recent change. `f128` tests are disabled on everything except x86_64 and Linux aarch64, which are two platforms I know have "good" support for these types - meaning basic math symbols are available and LLVM doesn't hit selection crashes. `f16` tests are enabled on almost everything except for known LLVM crashes. Doctests are only enabled on x86_64. Tracking issue: https://github.com/rust-lang/rust/issues/116909
2024-06-26Rollup merge of #126879 - the8472:next-chunk-filter-drop, r=cuviperMatthias Krüger-45/+45
fix Drop items getting leaked in Filter::next_chunk The optimization only makes sense for non-drop elements anyway. Use the default implementation for items that are Drop instead. It also simplifies the implementation. fixes #126872 tracking issue #98326
2024-06-26core: avoid `extern` types in formatting infrastructurejoboet-21/+25
2024-06-25fix UI test, simplify error messagejoboet-0/+6
2024-06-25add comments explaining optimizations for Filter::next_chunkThe 8472-1/+3
2024-06-25fix Drop items getting leaked in Filter::next_chunkThe 8472-45/+43
The optimization only makes sense for non-drop elements anyway. Use the default implementation for items that are Drop instead. It also simplifies the implementation.
2024-06-25Rollup merge of #126946 - cyrgani:patch-1, r=compiler-errorsMatthias Krüger-1/+1
Add missing slash in `const_eval_select` doc comment In the middle of the doc comment, one line has only two slashes instead of three and isn't included in the [rendered documentation](https://doc.rust-lang.org/std/intrinsics/fn.const_eval_select.html#stability-concerns). This PR adds the missing slash.
2024-06-25Rollup merge of #126927 - workingjubilee:vaargsafe-is-unsafe, r=joboetMatthias Krüger-4/+5
core: VaArgSafe is an unsafe trait `T: VaArgSafe` is relied on for soundness. Safe impls promise nothing. Therefore this must be an unsafe trait. Slightly pedantic, as only core can impl this, but we *could* choose to unseal the trait. That would allow soundly (but unsafely) implementing this for e.g. a `#[repr(C)] struct` that should be passable by varargs. Relates to https://github.com/rust-lang/rust/issues/44930
2024-06-25Rollup merge of #126302 - mu001999-contrib:ignore/default, r=michaelwoeristerMatthias Krüger-0/+1
Detect unused structs which derived Default <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Fixes #98871
2024-06-25Stabilize const unchecked conversion from u32 to charDavid Tolnay-3/+5
2024-06-25Detect unused structs which derived Defaultmu001999-0/+1
2024-06-25simd_bitmask intrinsic: add a non-power-of-2 multi-byte exampleRalf Jung-6/+13
2024-06-25Add missing slash in const_eval_select doc commentcyrgani-1/+1
2024-06-25Add more `f16` and `f128` library functions and constantsTrevor Gross-2/+1250
This adds everything that was directly or transitively blocked on const arithmetic for these types, which was recently merged. Since const arithmetic is recent, most of these need to be gated by `bootstrap`. Anything that relies on intrinsics that are still missing is excluded.
2024-06-25Add doctests to existing `f16` and `f128` functionsTrevor Gross-4/+68
The symbols that these tests rely on are not available on all platforms and some ABIs are buggy, tests that rely on external functions are configured to only run on x86 (`f128`) or aarch64 (`f16`).
2024-06-24core: VaArgSafe is an unsafe traitJubilee Young-4/+5
`T: VaArgSafe` is relied on for soundness. Safe impls promise nothing. Therefore this must be an unsafe trait. Slightly pedantic, as only core can impl this, but we could choose to unseal the trait. That would allow soundly (but unsafely) implementing this for e.g. a `#[repr(C)] struct` that should be passable by varargs.
2024-06-25Auto merge of #126852 - scottmcm:more-checked-math-tweaks, r=Amanieubors-2/+13
Also get `add nuw` from `uN::checked_add` When I was doing this for `checked_{sub,shl,shr}`, it was mentioned https://github.com/rust-lang/rust/pull/124114#issuecomment-2066173305 that it'd be worth trying for `checked_add` too. It makes a particularly-big difference for `x.checked_add(C)`, as doing this means that LLVM removes the intrinsic and does it as a normal `x <= MAX - C` instead. cc `@DianQK` who had commented about `checked_add` related to https://github.com/rust-lang/hashbrown/issues/509 before cc https://github.com/llvm/llvm-project/issues/80637 for how LLVM is unlikely to do this itself
2024-06-24Rollup merge of #126904 - GrigorenkoPV:nonzero-fixme, r=joboetMichael Goulet-13/+2
Small fixme in core now that NonZero is generic I doubt I have the rights to, but `@bors` rollup=always
2024-06-24Rollup merge of #125575 - dingxiangfei2009:derive-smart-ptr, r=davidtwcoMichael Goulet-0/+9
SmartPointer derive-macro <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r​? <reviewer name> --> Possibly replacing #123472 for continued upkeep of the proposal rust-lang/rfcs#3621 and implementation of the tracking issue #123430. cc `@Darksonn` `@wedsonaf`
2024-06-24Replace `MaybeUninit::uninit_array()` with array repeat expression.Kevin Reid-25/+25
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-24Small fixme in core now that split_first has no codegen issuesPavel Grigorenko-6/+2
2024-06-24Small fixme in core now that NonZero is genericPavel Grigorenko-13/+2
2024-06-24Rollup merge of #126213 - zachs18:atomicbool-u8-i8-from-ptr-alignment, ↵Matthias Krüger-17/+33
r=Nilstrieb Update docs for AtomicBool/U8/I8 with regard to alignment Fixes #126084. Since `AtomicBool`/`AtomicU8`/`AtomicI8` are guaranteed to have size == 1, and Rust guarantees that `size % align == 0`, they also must have alignment equal to 1, so some current docs are contradictory/confusing when describing their alignment requirements. Specifically: * Fix `AtomicBool::from_ptr` claiming that `align_of::<AtomicBool>() > align_of::<bool>()` on some platforms. (same for `AtomicU8::from_ptr`/`AtomicI8::from_ptr`) * Explicitly state that `AtomicU8`/`AtomicI8` have the same alignment as `u8`/`i8` (in addition to size and bit validity) * (internal) Change the `if_not_8_bit` macro to be `if_8_bit` and to allow an "if-else"-like structure, instead of just "if"-like. --- I opted to leave the "`ptr` must be aligned" wording in `from_ptr`'s docs and just clarify that it is always satsified, instead of just removing the wording entirely. If that is instead preferred I can do that.