about summary refs log tree commit diff
path: root/library/core
AgeCommit message (Collapse)AuthorLines
2025-01-24Rollup merge of #135938 - carlsverre:master, r=joboetMatthias Krüger-0/+20
Add memory layout documentation to generic NonZero<T> The documentation I've added is based on the same Layout documentation that appears on the other `NonZero*` types. For example see [the Layout docs on `NonZeroI8`](https://doc.rust-lang.org/std/num/type.NonZeroI8.html#layout-1).
2025-01-24Add an `unchecked_div` alias to the `Div<NonZero<_>>` implsScott McMurray-0/+7
2025-01-24Update library/core/src/num/nonzero.rs Carl Sverre-1/+1
Tweak language Co-authored-by: Jonas Böttiger <jonasboettiger@icloud.com>
2025-01-24ports last few library files to new intrinsic styleaaishwarymishra@gmail.com-677/+957
2025-01-24Remove a bunch of emscripten test ignoresbjorn3-34/+29
They are either outdated as emscripten now supports i128 or they are subsumed by #[cfg_attr(not(panic = "unwind"), ignore]
2025-01-24Rollup merge of #135489 - RalfJung:TryFromSliceError, r=tgross35Matthias Krüger-1/+0
remove pointless allowed_through_unstable_modules on TryFromSliceError This got added in https://github.com/rust-lang/rust/pull/132482 but the PR does not explain why. `@lukas-code` do you still remember? Also Cc `@Noratrieb` as reviewer of that PR. If I understand the issue description correctly, all paths under which this type is exported are stable now: `core::array::TryFromSliceError` and `std::array::TryFromSliceError`. If that is the case, we shouldn't have the attribute; it's a terrible hack that should only be used when needed to maintain backward compatibility. Getting some historic information right is IMO *not* sufficient justification to risk accidentally exposing this type via more unstable paths today or in the future.
2025-01-24Fix `FormattingOptions` instantiation with `Default`Yuri Astrakhan-1/+16
The `fill` value by default should be set to `' '` (space), but the current implementation uses `#[derive(Default)]` which sets it to `\0`
2025-01-23Rollup merge of #135073 - joshtriplett:bstr, r=BurntSushiMatthias Krüger-0/+649
Implement `ByteStr` and `ByteString` types Approved ACP: https://github.com/rust-lang/libs-team/issues/502 Tracking issue: https://github.com/rust-lang/rust/issues/134915 These types represent human-readable strings that are conventionally, but not always, UTF-8. The `Debug` impl prints non-UTF-8 bytes using escape sequences, and the `Display` impl uses the Unicode replacement character. This is a minimal implementation of these types and associated trait impls. It does not add any helper methods to other types such as `[u8]` or `Vec<u8>`. I've omitted a few implementations of `AsRef`, `AsMut`, and `Borrow`, when those would be the second implementation for a type (counting the `T` impl), to avoid potential inference failures. We can attempt to add more impls later in standalone commits, and run them through crater. In addition to the `bstr` feature, I've added a `bstr_internals` feature for APIs provided by `core` for use by `alloc` but not currently intended for stabilization. This API and its implementation are based *heavily* on the `bstr` crate by Andrew Gallant (`@BurntSushi).` r? `@BurntSushi`
2025-01-23Add memory layout documentation to generic NonZero<T>Carl Sverre-0/+20
2025-01-22Implement `AtomicT::update` & `AtomicT::try_update`Pavel Grigorenko-3/+374
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/+17
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/+17
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-21/+280
[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.