about summary refs log tree commit diff
path: root/library/core/src
AgeCommit message (Collapse)AuthorLines
2025-01-22Implement `CloneToUninit` for `ByteStr`Josh Triplett-0/+10
2025-01-22Add doc aliases for BStr and BStringJosh Triplett-0/+1
2025-01-22Add `AsyncFn*` to core preludeLukas Markeffsky-0/+3
2025-01-21Rollup merge of #135750 - scottmcm:cma-example, r=cuviperMatthias Krüger-2/+31
Add an example of using `carrying_mul_add` to write wider multiplication Just the basic quadratic version that you wouldn't actually use for really-big integers, but it's nice and short so is useful as for a demonstration of why you might find `carrying_mul_add` useful :) cc #85532 ``````@clarfonthey``````
2025-01-21optimize slice::ptr_rotate for compile-time-constant small rotatesedwloef-161/+166
2025-01-21[cfg_match] Document the use of expressionsCaio-0/+11
2025-01-20Auto merge of #134286 - Urgau:unreach_pub-std, r=ibraheemdevbors-100/+116
Enable `unreachable_pub` lint in core This PR enables the [`unreachable_pub`](https://doc.rust-lang.org/rustc/lints/listing/allowed-by-default.html#unreachable-pub) as warn in `core`, `rtstartup` and `panic_unwind`. The motivation is similar to the compiler [MCP: Enable deny(unreachable_pub) on `rustc_*` crates](https://github.com/rust-lang/compiler-team/issues/773#issue-2467219005) : > "Where is this thing used?" is a question I ask all the time when reading unfamiliar code. Because of this, I generally find it annoying when things are marked with a more permissive visibility than necessary. "This thing marked pub, which other crates is it used in? Oh, it's not used in any other crates." Another motivation is to help to lint by utilizing it in-tree and seeing it's limitation in more complex scenarios. The diff was mostly generated with `./x.py fix --stage 1 library/core/ -- --broken-code`, as well as manual edits for code in macros, generated code and other targets. r? libs
2025-01-20Rollup merge of #135741 - bardiharborow:std/net/rfc9637, r=AmanieuMatthias Krüger-4/+7
Recognise new IPv6 documentation range from IETF RFC 9637 This PR adds the `3fff::/20` range defined by [IETF RFC 9637](https://datatracker.ietf.org/doc/rfc9637/) to those ranges which `Ipv6Addr::is_documentation` recognises as a documentation IP. See also: https://www.iana.org/assignments/iana-ipv6-special-registry/iana-ipv6-special-registry.xhtml Unstable tracking issue: #27709
2025-01-20Rollup merge of #133695 - x17jiri:hint_likely, r=AmanieuMatthias Krüger-0/+135
Reexport likely/unlikely in std::hint Since `likely`/`unlikely` should be working now, we could reexport them in `std::hint`. I'm not sure if this is already approved or if it requires approval Tracking issue: #26179
2025-01-20core: `#[allow(unreachable_pub)]` on unreachable `pub use`Urgau-1/+9
2025-01-20core: add `#![warn(unreachable_pub)]`Urgau-99/+107
2025-01-201. Removed 'rustc_nounwind' 2. Rewording of commentsJiri Bobek-11/+6
2025-01-20Correct counting to four in cell module docsTom Fryers-2/+2
2025-01-19Add an example of using `carrying_mul_add` to write wider multiplicationScott McMurray-2/+31
Just the basic quadratic version that you wouldn't actually want for a true bigint, but it's nice and short so is useful as an example :)
2025-01-20Recognise new IPv6 documentation range from RFC9637Bardi Harborow-4/+7
This commit adds the 3fff::/20 range defined by RFC9637 to those ranges which Ipv6Addr::is_documentation recognises as a documentation IP.
2025-01-19Auto merge of #134976 - mgsloan:improve-select-nth-unstable-docs, r=ibraheemdevbors-42/+49
Improve `select_nth_unstable` documentation clarity * Instead uses `before` and `after` variable names in the example where `greater` and `lesser` are flipped. * Uses `<=` and `>=` instead of "less than or equal to" and "greater than or equal to" to make the docs more concise. * General attempt to remove unnecessary words and be more precise. For example it seems slightly wrong to say "its final sorted position", since this implies there is only one sorted position for this element.
2025-01-19Auto merge of #135709 - lqd:bring-back-len, r=compiler-errorsbors-1/+2
Temporarily bring back `Rvalue::Len` r? `@compiler-errors` as requested in https://github.com/rust-lang/rust/issues/135671#issuecomment-2599580364 > However, in the mean time, I'd rather we not crunch trying to find and more importantly validate the soundness of a solution 🤔 Agreed. To fix the IMO P-critical #135671 for which we somehow didn't have test coverage, this PR temporarily reverts: - https://github.com/rust-lang/rust/pull/133734 - its bugfix https://github.com/rust-lang/rust/pull/134371 - https://github.com/rust-lang/rust/pull/134330 cc `@scottmcm` I added the few samples from that issue as a test, but we can add more in the future, in particular it seems `@steffahn` [will work on that](https://github.com/rust-lang/rust/issues/135671#issuecomment-2599714354). Fixes #135671. And if we want to land this, it should also be nominated for beta backport.
2025-01-18Rewrap following accepting review suggestions from @ibraheemdevMichael Sloan-8/+18
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-2/+1
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-3/+3
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-2/+2
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-2/+2
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-3/+3
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-1/+1
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-1/+1
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-3/+3
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-1/+1
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Update library/core/src/slice/mod.rsMichael Sloan-2/+2
Co-authored-by: Ibraheem Ahmed <ibraheem@ibraheem.ca>
2025-01-18Revert "Auto merge of #134330 - scottmcm:no-more-rvalue-len, r=matthewjasper"Rémy Rakic-1/+2
This reverts commit e108481f74ff123ad98a63bd107a18d13035b275, reversing changes made to 303e8bd768526a5812bb1776e798e829ddb7d3ca.
2025-01-18`then be` -> `be` based on feedback from @ibraheemdevMichael Sloan-3/+3
2025-01-18re-export `core::iter::FromCoroutine`joseLuís-4/+4
2025-01-17Add references to the IEEE functions for `float_next_up_down`Trevor Gross-0/+24
Mention the IEEE function by name and create a doc alias of the same.
2025-01-17Stabilize `float_next_up_down`Trevor Gross-16/+8
FCP completed at [1]. Closes https://github.com/rust-lang/rust/issues/91399 [1]: https://github.com/rust-lang/rust/issues/91399#issuecomment-2598734570
2025-01-16Rollup merge of #133720 - c410-f3r:cfg-match-foo-bar-baz, r=joshtriplettMatthias Krüger-0/+52
[cfg_match] Adjust syntax A year has passed since the creation of #115585 and the feature, as expected, is not moving forward. Let's change that. This PR proposes changing the arm's syntax from `cfg(SOME_CONDITION) => { ... }` to `SOME_CODITION => {}`. ```rust match_cfg! { unix => { fn foo() { /* unix specific functionality */ } } target_pointer_width = "32" => { fn foo() { /* non-unix, 32-bit functionality */ } } _ => { fn foo() { /* fallback implementation */ } } } ``` Why? Because after several manual migrations in https://github.com/rust-lang/rust/pull/116342 it became clear, at least for me, that `cfg` prefixes are unnecessary, verbose and redundant. Again, everything is just a proposal to move things forward. If the shown syntax isn't ideal, feel free to close this PR or suggest other alternatives.
2025-01-15Less unsafe in `dangling`/`without_provenance`Scott McMurray-20/+19
2025-01-15Auto merge of #135555 - matthiaskrgr:rollup-jnqdbuu, r=matthiaskrgrbors-2/+2
Rollup of 5 pull requests Successful merges: - #135497 (fix typo in typenames of pin documentation) - #135522 (add incremental test for issue 135514) - #135523 (const traits: remove some known-bug that do not seem to make sense) - #135535 (Add GUI test for #135499) - #135541 (Methods of const traits are const) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-15Rollup merge of #135497 - DJMrTV:master, r=jhprattMatthias Krüger-2/+2
fix typo in typenames of pin documentation I noticed this whilst reading the documentation for pin. Basically there was just one to many closing angle brackets on the type parameters in the documentation where instead of being `Pin<&mut T>` it was `Pin<&mut T>>`
2025-01-15Export likely(), unlikely() and cold_path() in std::hintJiri Bobek-0/+140
2025-01-15fix typo in typenames of pin documentationDJMrTV-2/+2
2025-01-15Rollup merge of #135003 - RalfJung:deprecate-allowed-through-unstable, ↵Guillaume Gomez-4/+20
r=davidtwco deprecate `std::intrinsics::transmute` etc, use `std::mem::*` instead The `rustc_allowed_through_unstable_modules` attribute lets users call `std::mem::transmute` as `std::intrinsics::transmute`. The former is a reexport of the latter, and for a long time we didn't properly check stability for reexports, so making this a hard error now would be a breaking change for little gain. But at the same time, `std::intrinsics::transmute` is not the intended path for this function, so I think it is a good idea to show a deprecation warning when that path is used. This PR implements that, for all the functions in `std::intrinsics` that carry the attribute. I assume this will need ``@rust-lang/libs-api`` FCP.
2025-01-15Auto merge of #135525 - jhpratt:rollup-4gu2wpm, r=jhprattbors-32/+20
Rollup of 7 pull requests Successful merges: - #132397 (Make missing_abi lint warn-by-default.) - #133807 (ci: Enable opt-dist for dist-aarch64-linux builds) - #134143 (Convert `struct FromBytesWithNulError` into enum) - #134338 (Use a C-safe return type for `__rust_[ui]128_*` overflowing intrinsics) - #134678 (Update `ReadDir::next` in `std::sys::pal::unix::fs` to use `&raw const (*p).field` instead of `p.byte_offset().cast()`) - #135424 (Detect unstable lint docs that dont enable their feature) - #135520 (Make sure we actually use the right trivial lifetime substs when eagerly monomorphizing drop for ADTs) r? `@ghost` `@rustbot` modify labels: rollup
2025-01-15Rollup merge of #134143 - nyurik:err-nul, r=dtolnayJacob Pratt-32/+20
Convert `struct FromBytesWithNulError` into enum This PR renames the former `kind` enum from `FromBytesWithNulErrorKind` to `FromBytesWithNulError`, and removes the original struct. See https://github.com/rust-lang/libs-team/issues/493 ## Possible Changes - TBD * [x] should the new `enum FromBytesWithNulError` derive `Copy`? * [ ] should there be any new/changed attributes? * [x] add some more tests ## Problem One of `CStr` constructors, `CStr::from_bytes_with_nul(bytes: &[u8])` handles 3 cases: 1. `bytes` has one NULL as the last value - creates CStr 2. `bytes` has no NULL - error 3. `bytes` has a NULL in some other position - error The 3rd case is error that may require lossy conversion, but the 2nd case can easily be handled by the user code. Unfortunately, this function returns an opaque `FromBytesWithNulError` error in both 2nd and 3rd case, so the user cannot detect just the 2nd case - having to re-implement the entire function and bring in the `memchr` dependency. ## Motivating examples or use cases In [this code](https://github.com/gquintard/varnish-rs/blob/f86d7a87683b08d2e634d63e77d9dc1d24ed4a13/varnish-sys/src/vcl/ws.rs#L158), my FFI code needs to copy user's `&[u8]` into a C-allocated memory blob in a NUL-terminated `CStr` format. My code must first validate if `&[u8]` has a trailing NUL (case 1), no NUL (adds one on the fly - case 2), or NUL in the middle (3rd case - error). I had to re-implement `from_bytes_with_nul` and add `memchr`dependency just to handle the 2nd case. r? `@Amanieu`
2025-01-15intrinsics: deprecate calling them via the unstable std::intrinsics pathRalf Jung-4/+20
2025-01-14Enforce syntactical stability of const traits in HIRMichael Goulet-0/+6
2025-01-14remove pointless allowed_through_unstable_modules on TryFromSliceErrorRalf Jung-1/+0
2025-01-14remove Rustc{En,De}codable from library and compilerRalf Jung-35/+0
2025-01-14make rustc_encodable_decodable feature properly unstableRalf Jung-6/+3
2025-01-12Auto merge of #135384 - saethlin:inline-copy-from-slice, r=joboetbors-0/+1
Add #[inline] to copy_from_slice I'm doing cooked things to CGU partitioning for compiler-builtins (https://github.com/rust-lang/rust/pull/135395) and this was the lone symbol in my compiler-builtins rlib that wasn't an intrinsic. Adding `#[inline]` makes it go away. Perf report indicates a marginal but chaotic effect on compile time, marginal improvement in codegen. As expected.
2025-01-12Omit some more `From` impls to avoid inference failuresJosh Triplett-22/+26
2025-01-11Add inherent versions of MaybeUninit methods for slicesltdk-280/+386